/* COSMIC Desktop Preview
   Colors from pop-os/libcosmic cosmic-theme dark.ron palette
   Layout from cosmic-panel default_schema (Panel + Dock)
   File manager: COSMIC Files (com.system76.CosmicFiles)
*/

:root {
  /* Palette — cosmic-dark */
  --gray-1: #1b1b1b;
  --gray-2: #262626;
  --neutral-0: #000000;
  --neutral-2: #161616;
  --neutral-3: #2e2e2e;
  --neutral-4: #484848;
  --neutral-5: #636363;
  --neutral-6: #808080;
  --neutral-7: #9e9e9e;
  --neutral-8: #bebebe;
  --neutral-9: #dedede;
  --neutral-10: #ffffff;

  --accent: #63d0df;
  --accent-hover: #7ad9e6;
  --accent-deep: #229fad;
  --accent-fg: #000000;
  --danger: #fda1a0;
  --ext-orange: #ffad00;
  --ext-purple: #cf7dff;

  --panel-height: 32px;
  --panel-bg: rgba(27, 27, 27, 0.92);
  --panel-fg: var(--neutral-10);
  --panel-fg-dim: var(--neutral-8);

  --dock-height: 64px;
  --dock-bg: rgba(38, 38, 38, 0.88);
  --dock-radius: 22px;
  --dock-margin: 10px;
  --dock-padding: 6px;
  --dock-gap: 4px;

  --surface: var(--gray-2);
  --surface-raised: var(--neutral-3);
  --surface-hover: rgba(255, 255, 255, 0.08);
  --surface-active: rgba(99, 208, 223, 0.22);
  --surface-fg: var(--neutral-10);
  --surface-fg-dim: var(--neutral-7);
  --entry-bg: rgba(255, 255, 255, 0.08);
  --entry-border: rgba(255, 255, 255, 0.06);

  --shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  --shadow-soft: 0 4px 16px rgba(0, 0, 0, 0.35);
  --font: "Noto Sans", "Cantarell", "Ubuntu", system-ui, sans-serif;
  --transition: 160ms ease-out;

  --sym-filter: invert(1) brightness(1.1);
  --wallpaper: url("assets/wallpapers/orion-nebula.jpg");

  /* COSMIC Files window */
  --win-bg: #2a2a2a;
  --win-header: #323232;
  --win-sidebar: #262626;
  --win-content: #2a2a2a;
  --win-fg: #eeeeec;
  --win-fg-dim: #9a9a9a;
  --win-border: rgba(255, 255, 255, 0.06);
  --win-hover: rgba(255, 255, 255, 0.07);
  --win-selected: rgba(99, 208, 223, 0.28);
  --win-input: #3a3a3a;
  --win-shadow: 0 20px 56px rgba(0, 0, 0, 0.55);
  --win-radius: 12px;
  --close: #e35d4b;
  --close-hover: #f26d5b;
  --max: #63d0df;
  --min: #ffad00;
}

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  font-size: 13px;
  color: var(--panel-fg);
  background: #0a0a0c;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

img {
  display: block;
  max-width: 100%;
}

img.sym {
  filter: var(--sym-filter);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ---------- Desktop shell ---------- */

.desktop {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  user-select: none;
}

.wallpaper {
  position: absolute;
  inset: 0;
  background-image: var(--wallpaper);
  background-size: cover;
  background-position: center;
  z-index: 0;
}

/* ---------- Top Panel ---------- */

.top-panel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--panel-height);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 6px;
  background: var(--panel-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.35);
  z-index: 100;
  color: var(--panel-fg);
}

.panel-start,
.panel-end {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.panel-end {
  justify-content: flex-end;
}

.panel-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 26px;
  border-radius: 6px;
  transition: background var(--transition);
}

.panel-btn:hover,
.panel-btn[aria-expanded="true"] {
  background: var(--surface-hover);
}

.panel-btn img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.panel-clock {
  justify-self: center;
  padding: 2px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: background var(--transition);
  white-space: nowrap;
}

.panel-clock:hover,
.panel-clock[aria-expanded="true"] {
  background: var(--surface-hover);
}

.panel-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 26px;
  border-radius: 6px;
  color: var(--panel-fg);
  transition: background var(--transition);
}

.panel-icon-btn:hover,
.panel-icon-btn[aria-expanded="true"] {
  background: var(--surface-hover);
}

.panel-icon-btn img.sym {
  width: 16px;
  height: 16px;
}

.panel-icon-btn svg {
  opacity: 0.9;
}

/* ---------- Dock ---------- */

.dock {
  position: absolute;
  left: 50%;
  bottom: var(--dock-margin);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: var(--dock-gap);
  height: var(--dock-height);
  padding: var(--dock-padding) 10px;
  background: var(--dock-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: var(--dock-radius);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
  z-index: 90;
}

.dock-btn,
.dock-app {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  transition: background var(--transition), transform var(--transition);
  position: relative;
}

.dock-btn:hover,
.dock-app:hover {
  background: var(--surface-hover);
  transform: translateY(-2px);
}

.dock-btn img,
.dock-app img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 8px;
}

.dock-sep {
  width: 1px;
  height: 28px;
  background: rgba(255, 255, 255, 0.14);
  margin: 0 4px;
  flex-shrink: 0;
}

.dock-apps {
  display: flex;
  align-items: center;
  gap: var(--dock-gap);
}

.dock-app.active::after,
.dock-app.running::after {
  content: "";
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.dock-app.active {
  background: var(--surface-active);
}

/* ---------- Popovers (tray / calendar / power) ---------- */

.popover {
  position: absolute;
  z-index: 200;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 12px;
  min-width: 240px;
  color: var(--surface-fg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

.popover[hidden] {
  display: none !important;
}

.tray-popover {
  top: calc(var(--panel-height) + 6px);
  right: 8px;
}

.tray-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tray-slider {
  flex: 1;
  accent-color: var(--accent);
  height: 4px;
}

.tray-pct {
  min-width: 36px;
  text-align: right;
  font-size: 12px;
  color: var(--surface-fg-dim);
}

.tray-device {
  margin-top: 8px;
  font-size: 12px;
  color: var(--surface-fg-dim);
  padding-left: 26px;
}

.tray-status-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tray-name {
  font-weight: 500;
}

.tray-sub {
  font-size: 12px;
  color: var(--surface-fg-dim);
}

.notif-popover {
  min-width: 280px;
}

.notif-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 12px;
  color: var(--surface-fg-dim);
}

.notif-empty img.sym {
  width: 28px;
  height: 28px;
  opacity: 0.5;
}

.notif-empty p {
  margin: 0;
}

/* Calendar */

.calendar-popover {
  top: calc(var(--panel-height) + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: 280px;
  text-align: center;
}

.cal-time {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.cal-date-line {
  font-size: 13px;
  color: var(--surface-fg-dim);
  margin-top: 2px;
  margin-bottom: 14px;
}

.cal-month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.cal-month-label {
  font-weight: 600;
  font-size: 13px;
}

.cal-nav-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-size: 18px;
  line-height: 1;
  color: var(--surface-fg-dim);
}

.cal-nav-btn:hover {
  background: var(--surface-hover);
  color: var(--surface-fg);
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 4px;
  font-size: 11px;
  color: var(--surface-fg-dim);
  font-weight: 500;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 12px;
  color: var(--surface-fg);
}

.cal-day.muted {
  color: var(--neutral-5);
}

.cal-day.today {
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}

/* Power */

.power-popover {
  top: calc(var(--panel-height) + 6px);
  right: 8px;
  width: 280px;
  padding: 8px;
}

.power-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  text-align: left;
}

.power-item:hover {
  background: var(--surface-hover);
}

.power-label {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.power-title {
  font-weight: 500;
}

.power-shortcut {
  font-size: 11px;
  color: var(--surface-fg-dim);
}

.power-sep {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 6px 8px;
}

.power-icons-row {
  display: flex;
  gap: 4px;
  padding: 4px;
}

.power-icon-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 6px;
  border-radius: 8px;
  font-size: 11px;
  color: var(--surface-fg-dim);
}

.power-icon-btn:hover {
  background: var(--surface-hover);
  color: var(--surface-fg);
}

.power-icon-btn.danger:hover {
  background: rgba(253, 161, 160, 0.15);
  color: var(--danger);
}

.power-icon-btn img.sym {
  width: 22px;
  height: 22px;
}

.power-settings-btn {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  text-align: left;
  font-weight: 500;
}

.power-settings-btn:hover {
  background: var(--surface-hover);
}

/* ---------- Workspaces Overview (cosmic-workspaces-epoch) ----------
   Default layout: Vertical — sidebar left, toplevel previews right.
   Active workspace: 4px accent border. Labels: "Workspace N", "New Workspace".
*/

.workspaces-overview {
  position: absolute;
  inset: 0;
  z-index: 130;
  display: flex;
  padding: calc(var(--panel-height) + 12px) 16px calc(var(--dock-height) + var(--dock-margin) + 16px);
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.workspaces-overview[hidden] {
  display: none !important;
}

.ws-layout {
  display: flex;
  gap: 16px;
  width: 100%;
  height: 100%;
  min-height: 0;
}

/* Vertical strip of workspace thumbnails */
.ws-sidebar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  width: 240px;
  overflow-y: auto;
  padding: 8px 4px;
}

.ws-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px;
  border-radius: 14px;
  border: 4px solid transparent;
  background: transparent;
  transition: background var(--transition), border-color var(--transition);
  cursor: pointer;
}

.ws-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.ws-item.active {
  border-color: var(--accent);
  background: rgba(99, 208, 223, 0.08);
}

.ws-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: var(--neutral-2);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.ws-thumb-wallpaper {
  position: absolute;
  inset: 0;
  background-image: var(--wallpaper);
  background-size: cover;
  background-position: center;
}

.ws-thumb-windows {
  position: absolute;
  inset: 10%;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-content: flex-start;
}

.ws-mini-win {
  background: rgba(42, 42, 42, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ws-mini-win.w1 {
  width: 58%;
  height: 52%;
}

.ws-mini-win.w2 {
  width: 36%;
  height: 40%;
}

.ws-mini-win.w3 {
  width: 42%;
  height: 36%;
}

.ws-mini-titlebar {
  height: 10px;
  background: rgba(50, 50, 50, 0.95);
  display: flex;
  align-items: center;
  padding: 0 4px;
  gap: 2px;
  flex-shrink: 0;
}

.ws-mini-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
}

.ws-mini-body {
  flex: 1;
  background: linear-gradient(
    160deg,
    rgba(99, 208, 223, 0.12),
    rgba(38, 38, 38, 0.9)
  );
  display: flex;
  align-items: center;
  justify-content: center;
}

.ws-mini-body img {
  width: 40%;
  height: 40%;
  object-fit: contain;
  opacity: 0.85;
}

.ws-item-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 20px;
  padding: 0 4px;
}

.ws-item-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--surface-fg);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-new {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px 8px;
  border-radius: 14px;
  border: 2px dashed rgba(255, 255, 255, 0.18);
  color: var(--surface-fg-dim);
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.ws-new:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.3);
  color: var(--surface-fg);
}

.ws-new-plus {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 300;
  line-height: 1;
}

.ws-new-label {
  font-size: 12px;
  font-weight: 500;
}

/* Toplevel window previews (active workspace) */
.ws-toplevels {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 20px;
  padding: 12px 20px;
  overflow: auto;
}

.ws-toplevels-empty {
  color: var(--surface-fg-dim);
  font-size: 15px;
  text-align: center;
  opacity: 0.85;
}

.ws-window {
  display: flex;
  flex-direction: column;
  width: min(420px, 42vw);
  height: min(280px, 42vh);
  border-radius: 12px;
  overflow: hidden;
  background: var(--win-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  text-align: left;
  color: inherit;
}

.ws-window:hover {
  transform: scale(1.02);
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.6);
}

.ws-window-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--win-header);
  border-bottom: 1px solid var(--win-border);
  flex-shrink: 0;
}

.ws-window-header img.app-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  border-radius: 4px;
  flex-shrink: 0;
}

.ws-window-title {
  flex: 1;
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.ws-window-close {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition);
}

.ws-window-close:hover {
  background: rgba(227, 93, 75, 0.35);
}

.ws-window-close img.sym {
  width: 12px;
  height: 12px;
}

.ws-window-body {
  flex: 1;
  min-height: 0;
  position: relative;
  background: var(--win-content);
  overflow: hidden;
}

.ws-window-body .preview-files {
  display: flex;
  height: 100%;
}

.ws-window-body .preview-files-side {
  width: 28%;
  background: var(--win-sidebar);
  border-right: 1px solid var(--win-border);
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ws-window-body .preview-files-side span {
  height: 10px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
}

.ws-window-body .preview-files-side span:nth-child(1) {
  width: 70%;
  background: rgba(99, 208, 223, 0.25);
}

.ws-window-body .preview-files-main {
  flex: 1;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ws-window-body .preview-files-main .row {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 14px;
}

.ws-window-body .preview-files-main .row i {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: var(--accent-deep);
  opacity: 0.7;
  flex-shrink: 0;
}

.ws-window-body .preview-files-main .row b {
  flex: 1;
  height: 8px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.12);
}

.ws-window-body .preview-term {
  height: 100%;
  padding: 12px 14px;
  font-family: "Noto Sans Mono", "Ubuntu Mono", ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.45;
  color: #92cf9c;
  background: #161616;
}

.ws-window-body .preview-term .dim {
  color: var(--neutral-6);
}

.ws-window-body .preview-browser {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.ws-window-body .preview-browser .urlbar {
  height: 22px;
  margin: 8px 10px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.08);
}

.ws-window-body .preview-browser .page {
  flex: 1;
  margin: 0 10px 10px;
  border-radius: 6px;
  background: linear-gradient(180deg, #2a3540 0%, #1a2228 100%);
}

.ws-window-body .preview-generic {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ws-window-body .preview-generic img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  opacity: 0.9;
}

/* Hide desktop chrome windows under overview for cleaner mock */
.desktop.overview-open .files-window {
  visibility: hidden;
}

.desktop.overview-open .dock {
  opacity: 0.35;
  pointer-events: none;
}

@media (max-width: 800px) {
  .ws-sidebar {
    width: 160px;
  }

  .ws-window {
    width: min(300px, 70vw);
    height: min(200px, 36vh);
  }
}

/* ---------- Launcher ---------- */

.launcher-overlay {
  position: absolute;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: min(18vh, 140px);
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.launcher-overlay[hidden] {
  display: none !important;
}

.launcher-panel {
  width: min(560px, 92vw);
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.launcher-search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.launcher-search-icon {
  width: 18px;
  height: 18px;
  opacity: 0.7;
}

.launcher-search {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--surface-fg);
  font: inherit;
  font-size: 15px;
}

.launcher-search::placeholder {
  color: var(--surface-fg-dim);
}

.launcher-results {
  max-height: min(360px, 45vh);
  overflow-y: auto;
  padding: 6px;
}

.launcher-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  text-align: left;
}

.launcher-item:hover,
.launcher-item.focused {
  background: var(--surface-active);
}

.launcher-item img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 6px;
}

.launcher-item-name {
  font-weight: 500;
}

.launcher-item-desc {
  font-size: 12px;
  color: var(--surface-fg-dim);
}

.launcher-empty {
  padding: 24px;
  text-align: center;
  color: var(--surface-fg-dim);
  margin: 0;
}

/* ---------- App Library ---------- */

.app-library-overlay {
  position: absolute;
  inset: 0;
  z-index: 140;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px 96px;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.app-library-overlay[hidden] {
  display: none !important;
}

.app-library-panel {
  width: min(720px, 94vw);
  height: min(560px, 78vh);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.app-library-header {
  padding: 16px 18px 10px;
}

.app-library-search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--entry-bg);
  border-radius: 10px;
  border: 1px solid var(--entry-border);
}

.app-library-search {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--surface-fg);
  font: inherit;
  font-size: 14px;
}

.app-library-search::placeholder {
  color: var(--surface-fg-dim);
}

.app-library-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px 16px;
  min-height: 0;
}

.app-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}

.app-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 8px 12px;
  border-radius: 12px;
  transition: background var(--transition);
}

.app-tile:hover {
  background: var(--surface-hover);
}

.app-tile img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 10px;
}

.app-tile-name {
  font-size: 12px;
  text-align: center;
  line-height: 1.25;
  max-width: 100%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: var(--surface-fg);
}

.app-library-empty {
  text-align: center;
  color: var(--surface-fg-dim);
  padding: 40px 16px;
  margin: 0;
}

.app-library-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 10px 12px 12px;
  background: rgba(0, 0, 0, 0.15);
}

.app-library-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.app-group-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--surface-fg-dim);
  background: transparent;
  transition: background var(--transition), color var(--transition);
}

.app-group-btn:hover {
  background: var(--surface-hover);
  color: var(--surface-fg);
}

.app-group-btn.active {
  background: var(--surface-active);
  color: var(--accent);
}

.app-group-btn img {
  width: 16px;
  height: 16px;
  object-fit: contain;
  filter: var(--sym-filter);
  opacity: 0.85;
}

.app-group-btn.active img {
  opacity: 1;
}

/* ---------- COSMIC Files ---------- */

.files-window {
  position: absolute;
  top: calc(var(--panel-height) + 28px);
  left: 50%;
  transform: translateX(-50%);
  width: min(920px, 90vw);
  height: min(580px, calc(100vh - var(--panel-height) - var(--dock-height) - 56px));
  display: flex;
  flex-direction: column;
  background: var(--win-bg);
  border-radius: var(--win-radius);
  box-shadow: var(--win-shadow);
  border: 1px solid var(--win-border);
  z-index: 80;
  overflow: hidden;
  color: var(--win-fg);
}

.files-window[hidden] {
  display: none !important;
}

.files-window.maximized {
  top: var(--panel-height);
  left: 0;
  right: 0;
  bottom: calc(var(--dock-height) + var(--dock-margin) * 2);
  width: auto;
  height: auto;
  transform: none;
  border-radius: 0;
}

.files-headerbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 44px;
  padding: 0 8px 0 6px;
  background: var(--win-header);
  border-bottom: 1px solid var(--win-border);
  flex-shrink: 0;
}

.files-header-start,
.files-header-end {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.files-header-end {
  justify-content: flex-end;
}

.files-header-title {
  font-weight: 600;
  font-size: 13px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 8px;
}

.files-header-btn,
.files-tb-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  transition: background var(--transition);
}

.files-header-btn:hover,
.files-tb-btn:hover {
  background: var(--win-hover);
}

.files-header-btn[aria-pressed="true"],
.files-tb-btn.active,
.files-tb-btn[aria-pressed="true"] {
  background: var(--win-selected);
}

.files-header-btn:disabled,
.files-tb-btn:disabled {
  opacity: 0.35;
  pointer-events: none;
}

.files-menu-dropdown {
  position: relative;
}

.files-menu-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 13px;
}

.files-menu-btn:hover,
.files-menu-btn[aria-expanded="true"] {
  background: var(--win-hover);
}

.files-menu-caret {
  font-size: 10px;
  opacity: 0.7;
}

.files-menu-popup {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 140px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  box-shadow: var(--shadow-soft);
  padding: 4px;
  z-index: 20;
}

.files-menu-popup[hidden] {
  display: none !important;
}

.files-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
}

.files-menu-item:hover {
  background: var(--surface-hover);
}

/* Window controls — Cosmic style (right side, colored) */
.files-window-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
}

.files-wc {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  position: relative;
}

.files-wc::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0.95;
}

.files-min::before {
  background: var(--min);
}
.files-max::before {
  background: var(--max);
}
.files-close::before {
  background: var(--close);
}

.files-wc:hover::before {
  filter: brightness(1.12);
}

/* Toolbar / path bar */
.files-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--win-header);
  border-bottom: 1px solid var(--win-border);
  flex-shrink: 0;
}

.files-nav-group,
.files-view-group {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.files-pathbar {
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
  background: var(--win-input);
  border-radius: 8px;
  padding: 2px 4px;
  min-height: 32px;
}

.files-crumb {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 13px;
  max-width: 100%;
}

.files-crumb:hover {
  background: var(--win-hover);
}

.files-crumb img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.files-crumb span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.files-search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--win-header);
  border-bottom: 1px solid var(--win-border);
}

.files-search-bar[hidden] {
  display: none !important;
}

.files-search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--win-fg);
  font: inherit;
  font-size: 13px;
}

.files-search-input::placeholder {
  color: var(--win-fg-dim);
}

/* Body */
.files-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.files-sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--win-sidebar);
  border-right: 1px solid var(--win-border);
  overflow-y: auto;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.files-sidebar[hidden],
.files-window.sidebar-collapsed .files-sidebar {
  display: none;
}

.files-sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  text-align: left;
  font-size: 13px;
  color: var(--win-fg);
}

.files-sidebar-item:hover {
  background: var(--win-hover);
}

.files-sidebar-item.active {
  background: var(--win-selected);
  color: var(--accent);
  font-weight: 500;
}

.files-sidebar-item img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  flex-shrink: 0;
}

.files-sidebar-item.active img.sym,
.files-sidebar-item img.sym {
  filter: var(--sym-filter);
}

.files-sidebar-sep {
  height: 1px;
  background: var(--win-border);
  margin: 6px 8px;
}

.files-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--win-content);
}

.files-content {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 12px;
}

/* List view (default) */
.files-list-header {
  display: none;
  grid-template-columns: 36px 1fr 140px 80px;
  gap: 8px;
  padding: 8px 10px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--win-fg-dim);
  border-bottom: 1px solid var(--win-border);
  position: sticky;
  top: 0;
  background: var(--win-content);
  z-index: 1;
}

.files-content.view-list .files-list-header {
  display: grid;
}

.files-row {
  display: grid;
  grid-template-columns: 36px 1fr 140px 80px;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: default;
}

.files-row:hover {
  background: var(--win-hover);
}

.files-row.selected {
  background: var(--win-selected);
}

.files-row img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 4px;
}

.files-row-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.files-row-modified,
.files-row-size {
  font-size: 12px;
  color: var(--win-fg-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.files-row-size {
  text-align: right;
}

/* Grid view */
.files-content.view-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 4px;
  align-content: start;
  padding: 12px;
}

.files-content.view-grid .files-list-header {
  display: none;
}

.files-content.view-grid .files-row {
  display: flex;
  flex-direction: column;
  grid-template-columns: none;
  gap: 8px;
  padding: 12px 8px;
  text-align: center;
}

.files-content.view-grid .files-row img {
  width: 56px;
  height: 56px;
  margin: 0 auto;
}

.files-content.view-grid .files-row-name {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 12px;
  line-height: 1.3;
}

.files-content.view-grid .files-row-modified,
.files-content.view-grid .files-row-size {
  display: none;
}

.files-empty {
  grid-column: 1 / -1;
  padding: 48px 16px;
  text-align: center;
  color: var(--win-fg-dim);
}

/* ---------- Scrollbars ---------- */

.files-content::-webkit-scrollbar,
.files-sidebar::-webkit-scrollbar,
.app-library-body::-webkit-scrollbar,
.launcher-results::-webkit-scrollbar {
  width: 10px;
}

.files-content::-webkit-scrollbar-thumb,
.files-sidebar::-webkit-scrollbar-thumb,
.app-library-body::-webkit-scrollbar-thumb,
.launcher-results::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 5px;
  border: 2px solid transparent;
  background-clip: content-box;
}

/* ---------- Responsive ---------- */

@media (max-width: 700px) {
  .files-window {
    width: 96vw;
    height: calc(100vh - var(--panel-height) - var(--dock-height) - 40px);
  }

  .files-sidebar {
    width: 160px;
  }

  .files-row,
  .files-list-header {
    grid-template-columns: 32px 1fr 100px;
  }

  .files-row-size,
  .flh-size {
    display: none;
  }

  .dock {
    max-width: 96vw;
    overflow-x: auto;
  }

  .app-library-panel {
    height: min(520px, 75vh);
  }
}
