/* Caelestia-inspired desktop shell for body[data-layout="os"].
 *
 * The structure follows the Caelestia Quickshell modules kept under
 * reference-ui/shell-qml: a floating bar (logo, workspaces, active window,
 * clock, status cluster), a tabbed dashboard over the bar, and rounded
 * surface-container cards with generous radii instead of hard borders.
 *
 * Everything here is opt-in: the bar and dashboard only render for the
 * "Windows desktop" layout, so the default site chrome is untouched. */

:root {
  --cs-surface: rgba(16, 19, 28, 0.72);
  --cs-surface-2: rgba(26, 30, 42, 0.78);
  --cs-surface-3: rgba(38, 43, 58, 0.72);
  --cs-line: rgba(255, 255, 255, 0.14);
  --cs-line-soft: rgba(255, 255, 255, 0.08);
  --cs-text: #eef1fa;
  --cs-muted: #a7b0c8;
  --cs-radius: 22px;
  --cs-radius-lg: 28px;
  --cs-blur: blur(34px) saturate(170%);
}

/* ---------- top bar ---------- */

.cs-topbar {
  display: none;
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 325;
  align-items: center;
  gap: 6px;
  max-width: calc(100vw - 20px);
  height: 46px;
  padding: 5px 8px;
  border: 1px solid var(--cs-line);
  border-radius: 999px;
  color: var(--cs-text);
  background: var(--cs-surface);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  backdrop-filter: var(--cs-blur);
  -webkit-backdrop-filter: var(--cs-blur);
}

body[data-layout="os"] .cs-topbar {
  display: flex;
}

body.vm-desktop-active .cs-topbar,
body.vm-desktop-active .cs-dashboard,
body.landing .cs-topbar,
body.landing .cs-dashboard {
  display: none !important;
}

.cs-group {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.cs-group-center {
  flex: 1;
  justify-content: center;
}

.cs-logo,
.cs-tray,
.cs-icon-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  color: var(--cs-text);
  background: transparent;
  cursor: pointer;
  transition: background 0.16s ease, transform 0.16s ease;
}

.cs-logo:hover,
.cs-tray:hover,
.cs-icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.cs-logo:active,
.cs-tray:active,
.cs-icon-btn:active {
  transform: scale(0.94);
}

.cs-logo img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

/* Workspaces: one dot per open window. */
.cs-workspaces {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 6px;
  min-width: 0;
}

.cs-workspace {
  width: 8px;
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  cursor: pointer;
  transition: width 0.2s ease, background 0.2s ease;
}

.cs-workspace[data-active="true"] {
  width: 20px;
  background: var(--accent2, #9fb0e0);
}

.cs-workspace:hover {
  background: rgba(255, 255, 255, 0.45);
}

.cs-workspace[data-active="true"]:hover {
  background: var(--accent2, #9fb0e0);
}

.cs-active-window {
  max-width: 180px;
  overflow: hidden;
  padding: 0 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--cs-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cs-clock-btn {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 7px 14px;
  border: 0;
  border-radius: 999px;
  color: var(--cs-text);
  background: transparent;
  font: inherit;
  cursor: pointer;
  transition: background 0.16s ease;
}

.cs-clock-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.cs-clock-time {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.cs-clock-date {
  font-size: 11.5px;
  color: var(--cs-muted);
}

.cs-status {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--cs-muted);
  font-variant-numeric: tabular-nums;
}

.cs-status svg {
  width: 15px;
  height: 15px;
}

/* ---------- dashboard ---------- */

.cs-dashboard {
  display: none;
  position: fixed;
  top: 66px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  z-index: 330;
  width: min(880px, calc(100vw - 24px));
  max-height: calc(100vh - 160px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--cs-line);
  border-radius: var(--cs-radius-lg);
  color: var(--cs-text);
  background: rgba(13, 16, 24, 0.86);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  backdrop-filter: var(--cs-blur);
  -webkit-backdrop-filter: var(--cs-blur);
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

body[data-layout="os"] .cs-dashboard[data-cs-open="true"] {
  display: block;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.cs-dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.cs-user {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.cs-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 16px;
  background: linear-gradient(140deg, var(--accent, #a68369), var(--accent2, #9fb0e0));
  font-size: 16px;
  font-weight: 800;
  color: #10131c;
}

.cs-user-copy {
  min-width: 0;
}

.cs-user-copy strong {
  display: block;
  font-size: 14px;
  line-height: 1.2;
}

.cs-user-copy small {
  font-size: 11.5px;
  color: var(--cs-muted);
}

.cs-big-clock {
  text-align: right;
}

.cs-big-clock strong {
  display: block;
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.cs-big-clock span {
  font-size: 11.5px;
  color: var(--cs-muted);
}

.cs-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.cs-tab {
  flex: 1;
  padding: 8px 12px;
  border: 0;
  border-radius: 999px;
  color: var(--cs-muted);
  background: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}

.cs-tab:hover {
  color: var(--cs-text);
}

.cs-tab[aria-selected="true"] {
  color: #10131c;
  background: var(--accent2, #9fb0e0);
}

.cs-panel[hidden] {
  display: none !important;
}

.cs-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 12px;
}

.cs-card {
  padding: 16px;
  border: 1px solid var(--cs-line-soft);
  border-radius: var(--cs-radius);
  background: var(--cs-surface-2);
}

.cs-card h3 {
  margin: 0 0 2px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cs-muted);
}

.cs-card p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--cs-muted);
}

.cs-card-wide {
  grid-column: 1 / -1;
}

/* Month grid */
.cs-calendar-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.cs-calendar-head b {
  font-size: 14px;
}

.cs-calendar-head span {
  font-size: 11.5px;
  color: var(--cs-muted);
}

.cs-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px;
}

.cs-calendar-grid span {
  display: grid;
  place-items: center;
  height: 26px;
  border-radius: 999px;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--cs-muted);
}

.cs-calendar-grid span[data-weekday="true"] {
  height: 20px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.42);
}

.cs-calendar-grid span[data-today="true"] {
  color: #10131c;
  font-weight: 800;
  background: var(--accent2, #9fb0e0);
}

/* Quick actions */
.cs-actions {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.cs-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--cs-line-soft);
  border-radius: 14px;
  color: var(--cs-text);
  background: var(--cs-surface-3);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.16s ease, transform 0.16s ease;
}

.cs-action:hover {
  background: rgba(255, 255, 255, 0.16);
  transform: translateX(2px);
}

.cs-action span:last-child {
  color: var(--cs-muted);
}

/* Media panel */
.cs-media {
  display: flex;
  align-items: center;
  gap: 14px;
}

.cs-media-art {
  display: grid;
  place-items: center;
  flex: none;
  width: 96px;
  height: 96px;
  overflow: hidden;
  border-radius: 20px;
  background: linear-gradient(140deg, rgba(166, 131, 105, 0.55), rgba(159, 176, 224, 0.45));
  color: rgba(255, 255, 255, 0.85);
}

.cs-media-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cs-media-copy {
  min-width: 0;
}

.cs-media-title {
  overflow: hidden;
  font-size: 15px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cs-media-meta {
  margin: 2px 0 10px;
  font-size: 12px;
  color: var(--cs-muted);
}

.cs-media-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--cs-muted);
}

.cs-media-state i {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.3);
}

.cs-media-state[data-playing="true"] i {
  background: #7ee2a8;
  box-shadow: 0 0 10px rgba(126, 226, 168, 0.7);
}

.cs-media-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}

.cs-media-actions .cs-icon-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--cs-line-soft);
  background: var(--cs-surface-3);
  font-size: 11px;
  line-height: 1;
}

.cs-media-actions .cs-icon-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Resource meters */
.cs-meters {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.cs-meter {
  display: grid;
  gap: 5px;
}

.cs-meter-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 12px;
}

.cs-meter-head span:first-child {
  color: var(--cs-muted);
}

.cs-meter-head span:last-child {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.cs-meter-bar {
  position: relative;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.cs-meter-bar i {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent, #a68369), var(--accent2, #9fb0e0));
  transition: width 0.3s ease;
}

/* ---------- app windows ---------- */

.os-window {
  position: fixed;
  display: flex;
  flex-direction: column;
  width: min(1000px, calc(100vw - 160px));
  height: min(680px, calc(100vh - 200px));
  overflow: hidden;
  border: 1px solid var(--cs-line);
  border-radius: 20px;
  color: var(--cs-text);
  background: rgba(14, 17, 26, 0.92);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  backdrop-filter: var(--cs-blur);
  -webkit-backdrop-filter: var(--cs-blur);
}

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

.os-window.maximized {
  border-radius: 14px;
}

.os-window-titlebar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--cs-line-soft);
  background: rgba(255, 255, 255, 0.05);
  cursor: grab;
  user-select: none;
}

.os-window-titlebar:active {
  cursor: grabbing;
}

.os-window-controls {
  display: flex;
  gap: 6px;
}

.os-win-btn {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  color: var(--cs-text);
  background: rgba(255, 255, 255, 0.12);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease;
}

.os-win-btn:hover {
  background: rgba(255, 255, 255, 0.24);
}

.os-win-btn.close:hover {
  background: #e5534b;
}

.os-window-title {
  flex: 1;
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.os-window-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: rgba(8, 10, 16, 0.55);
}

.os-window-body > .view {
  height: 100%;
  overflow: auto;
  padding: 18px;
}

/* ---------- launcher (start menu) restyle ---------- */

body[data-layout="os"] .os-start-menu {
  border-radius: 26px;
  border-color: var(--cs-line);
  background: rgba(16, 19, 28, 0.9);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  backdrop-filter: var(--cs-blur);
  -webkit-backdrop-filter: var(--cs-blur);
}

body[data-layout="os"] .os-start-search {
  height: 40px;
  border-radius: 999px;
  border-color: var(--cs-line);
  background: rgba(255, 255, 255, 0.07);
}

body[data-layout="os"] .os-start-search button {
  color: var(--cs-muted);
}

body[data-layout="os"] .os-pinned a {
  border-radius: 14px;
}

body[data-layout="os"] .os-workspace-actions button {
  border-radius: 999px;
}

body[data-layout="os"] .os-start-footer {
  border-radius: 0 0 18px 18px;
}

/* Keep the desktop widgets clear of the new bar. */
body[data-layout="os"] #v-home:not([hidden]) .os-desktop-widgets {
  top: 76px;
}

@media (max-width: 820px) {
  .cs-active-window,
  .cs-clock-date {
    display: none;
  }

  .cs-dashboard {
    top: 62px;
    padding: 14px;
  }

  .cs-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .os-window {
    width: calc(100vw - 24px);
    height: calc(100vh - 170px);
  }
}
