:root {
  --bg: #0d1016;
  --surface: rgba(25, 28, 36, 0.82);
  --border: rgba(255, 255, 255, 0.13);
  --border-soft: rgba(255, 255, 255, 0.08);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.58);
  --faint: rgba(255, 255, 255, 0.34);
  --accent: #8ab4ff;
  --success: #30d158;
  --danger: #ff5f57;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", sans-serif;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

button,
input,
select,
textarea { font: inherit; }

button { color: inherit; }

.wallpaper {
  position: fixed;
  inset: 0;
  --daily-wallpaper: none;
  background:
    linear-gradient(122deg, rgba(255, 255, 255, 0.055), transparent 34%),
    linear-gradient(250deg, rgba(92, 120, 150, 0.20), transparent 42%),
    linear-gradient(180deg, #171b24 0%, #0d1016 54%, #080a0f 100%);
}

.wallpaper::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  background-image: var(--daily-wallpaper);
  background-position: center;
  background-size: cover;
  transform: scale(1.01);
  transition: opacity 420ms ease;
}

.wallpaper::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.18;
  background-image:
    linear-gradient(115deg, transparent 0 46%, rgba(255, 255, 255, 0.045) 46.3% 46.7%, transparent 47% 100%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 5px);
  mix-blend-mode: screen;
}

body.wallpaper-bing .wallpaper {
  background:
    linear-gradient(180deg, #141820 0%, #0c1018 100%);
}

body.wallpaper-bing .wallpaper::before {
  opacity: 1;
}

body.wallpaper-bing .wallpaper::after {
  opacity: 1;
  background:
    linear-gradient(180deg, rgba(4, 6, 10, 0.16), rgba(4, 6, 10, 0.48)),
    radial-gradient(circle at 50% 28%, transparent 0 34%, rgba(0, 0, 0, 0.20) 72%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 5px);
  mix-blend-mode: normal;
}

body.wallpaper-sonoma .wallpaper {
  background:
    linear-gradient(130deg, rgba(64, 108, 122, 0.34), transparent 36%),
    linear-gradient(236deg, rgba(146, 91, 68, 0.22), transparent 44%),
    linear-gradient(180deg, #172022 0%, #101419 58%, #090b0f 100%);
}

body.wallpaper-midnight .wallpaper {
  background:
    linear-gradient(120deg, rgba(54, 79, 128, 0.28), transparent 34%),
    linear-gradient(246deg, rgba(30, 64, 72, 0.20), transparent 45%),
    linear-gradient(180deg, #101622 0%, #0a0d14 58%, #05070b 100%);
}

.desktop-ui,
.login-screen,
.sheet-window,
.toast {
  position: relative;
  z-index: 2;
}

.desktop-ui {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  opacity: 1;
  transition: opacity 160ms ease;
}

.locked .desktop-ui {
  opacity: 0;
  pointer-events: none;
}

.login-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
}

body:not(.locked) .login-screen {
  opacity: 0;
  pointer-events: none;
}

.login-sheet,
.sheet-window {
  background: rgba(20, 23, 30, 0.78);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(30px) saturate(145%);
  -webkit-backdrop-filter: blur(30px) saturate(145%);
}

.login-sheet {
  width: min(360px, 100%);
  padding: 30px;
}

.login-mark {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  color: #101318;
  background: linear-gradient(135deg, #f4f6fb, #aeb8c8);
  font-weight: 700;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.26);
}

.login-sheet h1 {
  margin: 0;
  text-align: center;
  font-size: 24px;
  line-height: 1.1;
  font-weight: 650;
}

.login-sheet p {
  margin: 8px 0 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

label {
  display: block;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.password-row {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 8px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

textarea {
  min-height: 82px;
  padding-top: 11px;
  resize: none;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  border-color: rgba(138, 180, 255, 0.78);
  box-shadow: 0 0 0 3px rgba(138, 180, 255, 0.18);
  outline: none;
}

.password-row button,
.primary-btn {
  border: 1px solid rgba(138, 180, 255, 0.52);
  border-radius: 10px;
  background: rgba(138, 180, 255, 0.22);
  color: #edf4ff;
  cursor: pointer;
}

.password-row button svg,
.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.login-error {
  min-height: 18px;
  margin-top: 12px;
  color: #ffb4ad;
  font-size: 13px;
}

.menubar {
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(170px, 1fr);
  align-items: center;
  gap: 18px;
  padding: 10px 22px;
  background: linear-gradient(180deg, rgba(8, 10, 14, 0.54), rgba(8, 10, 14, 0.18));
  border-bottom: 1px solid rgba(255, 255, 255, 0.075);
  backdrop-filter: blur(28px) saturate(145%);
  -webkit-backdrop-filter: blur(28px) saturate(145%);
}

.menu-left,
.menu-actions,
.server-block,
.metric,
.dock,
.app-summary,
.window-actions {
  display: flex;
  align-items: center;
}

.menu-left {
  gap: 12px;
  min-width: 0;
}

.apple-dot,
.icon-btn,
.avatar-btn {
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
}

.apple-dot {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--text);
  font-size: 17px;
  line-height: 1;
}

.apple-dot:hover,
.icon-btn:hover,
.avatar-btn:hover {
  background: rgba(255, 255, 255, 0.075);
  border-color: var(--border-soft);
}

.server-block {
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.server-block strong {
  max-width: 240px;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.server-block span {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--success);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.5px;
}

.server-block i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.menu-metrics {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: var(--muted);
}

.metric {
  gap: 7px;
  min-width: 88px;
}

.metric span {
  color: var(--faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.metric b,
.network-stat {
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

meter {
  width: 40px;
  height: 4px;
}

meter::-webkit-meter-bar {
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.13);
}

meter::-webkit-meter-optimum-value {
  border-radius: 10px;
  background: var(--accent);
}

meter::-moz-meter-bar {
  border-radius: 10px;
  background: var(--accent);
}

.menu-actions {
  justify-content: flex-end;
  gap: 8px;
}

.icon-btn,
.avatar-btn {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
}

.has-dot::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--danger);
}

.avatar-btn {
  background: rgba(255, 255, 255, 0.09);
  font-size: 12px;
  font-weight: 700;
}

.desktop {
  position: relative;
  min-height: 0;
  padding: 34px clamp(20px, 4vw, 52px) 110px;
}

.clock-block {
  position: absolute;
  top: clamp(60px, 12vh, 130px);
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}

.clock-line {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 12px;
}

#clock-main {
  font-size: clamp(58px, 8vw, 108px);
  font-weight: 200;
  line-height: 0.92;
  letter-spacing: 0;
}

.clock-seconds {
  min-width: 30px;
  color: var(--faint);
  font-size: clamp(16px, 1.8vw, 24px);
  font-weight: 450;
}

.clock-seconds::before {
  content: ".";
  margin-right: 10px;
  color: rgba(255, 255, 255, 0.28);
}

.date-line {
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 450;
}

.desktop-icons {
  position: absolute;
  top: 92px;
  left: clamp(18px, 3vw, 42px);
  bottom: 110px;
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(6, 92px);
  grid-auto-columns: 92px;
  gap: 12px 18px;
  align-content: start;
  justify-content: start;
}

.app-icon {
  position: relative;
  width: 92px;
  min-height: 92px;
  border: 1px solid transparent;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.app-icon:hover,
.app-icon:focus-visible {
  background: rgba(255, 255, 255, 0.065);
  border-color: rgba(255, 255, 255, 0.08);
}

.app-icon img,
.dock-item img,
.fallback-icon {
  display: block;
  object-fit: cover;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.38));
}

.app-icon img,
.fallback-icon {
  width: 62px;
  height: 62px;
  border-radius: 14px;
}

.fallback-icon {
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #252a35, #151922);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--muted);
  font-size: 22px;
  font-weight: 700;
}

.app-icon span {
  max-width: 80px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 11px;
  line-height: 1.15;
  text-align: center;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.72);
  overflow-wrap: anywhere;
}

.app-settings-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  display: grid;
  place-items: center;
  opacity: 0;
  background: rgba(10, 12, 16, 0.72);
  color: var(--text);
  cursor: pointer;
  transition: opacity 120ms ease;
}

.app-icon:hover .app-settings-btn,
.app-icon:focus-within .app-settings-btn {
  opacity: 1;
}

.dock-wrap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 18px;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.dock {
  min-height: 74px;
  max-width: calc(100vw - 28px);
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(18, 21, 28, 0.58);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(26px) saturate(150%);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
  pointer-events: auto;
  overflow-x: auto;
}

.dock-item {
  position: relative;
  width: 54px;
  height: 58px;
  border: 1px solid transparent;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: transparent;
  cursor: pointer;
  flex: 0 0 auto;
}

.dock-item img,
.dock-item .fallback-icon {
  width: 46px;
  height: 46px;
  border-radius: 11px;
}

.dock-item:hover {
  transform: translateY(-5px) scale(1.08);
}

.dock-item::after {
  content: "";
  position: absolute;
  bottom: -2px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.52);
  opacity: 0;
}

.dock-item.is-favorite::after {
  opacity: 1;
}

.sheet-window {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(430px, calc(100vw - 28px));
  overflow: hidden;
  transform: translate(-50%, -48%) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
  z-index: 20;
}

.sheet-window.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.window-titlebar {
  height: 42px;
  display: grid;
  grid-template-columns: 54px 1fr 54px;
  align-items: center;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.045);
}

.window-titlebar span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-align: center;
}

.window-dot {
  width: 13px;
  height: 13px;
  margin-left: 18px;
  border: 0;
  border-radius: 50%;
  background: var(--danger);
  cursor: pointer;
}

.window-body {
  padding: 20px;
}

.app-summary {
  gap: 12px;
  margin-bottom: 18px;
}

.app-summary img {
  width: 48px;
  height: 48px;
  border-radius: 11px;
}

.app-summary strong,
.app-summary span {
  display: block;
}

.app-summary strong {
  font-size: 16px;
  line-height: 1.25;
}

.app-summary span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.field-grid {
  display: grid;
  gap: 8px;
  margin: 14px 0 18px;
}

.check-row {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}

.check-row input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

.window-body > label:not(:first-child) {
  margin-top: 14px;
}

.window-actions {
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.primary-btn,
.secondary-btn {
  min-height: 38px;
  padding: 0 15px;
  border-radius: 10px;
  cursor: pointer;
}

.secondary-btn {
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.055);
}

.toast {
  position: fixed;
  top: 76px;
  left: 50%;
  max-width: calc(100vw - 32px);
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: rgba(18, 21, 28, 0.86);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.28);
  color: var(--text);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-8px);
  transition: opacity 160ms ease, transform 160ms ease;
  white-space: nowrap;
  z-index: 40;
}

.toast.is-on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 980px) {
  .menubar {
    grid-template-columns: 1fr auto;
  }

  .menu-metrics {
    display: none;
  }

  .desktop-icons {
    grid-template-rows: repeat(5, 92px);
  }
}

@media (max-width: 680px) {
  .menubar {
    min-height: 54px;
    padding: 9px 12px;
    gap: 8px;
  }

  .server-block strong {
    max-width: 150px;
  }

  .desktop {
    padding-inline: 12px;
  }

  .clock-block {
    top: 70px;
    width: 100%;
  }

  .desktop-icons {
    top: 178px;
    left: 50%;
    bottom: 104px;
    grid-auto-flow: row;
    grid-template-columns: repeat(3, 92px);
    grid-template-rows: none;
    justify-content: center;
    transform: translateX(-50%);
    overflow: auto;
    width: min(310px, calc(100vw - 16px));
  }

  .dock {
    min-height: 66px;
    padding: 8px 10px;
    border-radius: 18px;
  }

  .dock-item {
    width: 48px;
    height: 52px;
  }

  .dock-item img,
  .dock-item .fallback-icon {
    width: 40px;
    height: 40px;
  }
}

.desktop-ui {
  display: block;
}

.floating-actions {
  position: fixed;
  top: 18px;
  right: 20px;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 8px;
}

.floating-actions .icon-btn,
.floating-actions .avatar-btn {
  width: 38px;
  height: 38px;
  border-color: transparent;
  background: transparent;
  color: rgba(255, 255, 255, 0.86);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.62);
}

.floating-actions .icon-btn:hover,
.floating-actions .avatar-btn:hover,
.floating-actions .icon-btn:focus-visible,
.floating-actions .avatar-btn:focus-visible {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.floating-actions .avatar-btn {
  font-size: 13px;
  font-weight: 700;
}

.desktop {
  min-height: 100vh;
  padding: 0 clamp(18px, 4vw, 52px) 112px;
}

.stats-widgets {
  position: fixed;
  top: 34px;
  left: clamp(18px, 3vw, 42px);
  z-index: 4;
  width: min(330px, calc(100vw - 36px));
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.server-widget,
.stats-widgets .metric,
.stats-widgets .network-stat {
  min-height: 76px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  background: rgba(13, 16, 22, 0.36);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(20px) saturate(135%);
  -webkit-backdrop-filter: blur(20px) saturate(135%);
}

.server-widget {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 14px 16px;
}

.server-widget strong {
  overflow: hidden;
  color: var(--text);
  font-size: 16px;
  font-weight: 650;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.server-widget span {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
}

.server-widget i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}

.stats-widgets .metric {
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 7px;
  padding: 12px 14px;
}

.stats-widgets .metric span {
  font-size: 10px;
}

.stats-widgets .metric b {
  font-size: 20px;
  font-weight: 600;
}

.stats-widgets meter {
  width: 100%;
  height: 5px;
}

.stats-widgets .network-stat {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 14px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
}

.clock-block {
  top: clamp(62px, 11vh, 118px);
}

.desktop-icons {
  top: auto;
  left: 50%;
  right: auto;
  bottom: 118px;
  width: min(820px, calc(100vw - 34px));
  display: grid;
  grid-auto-flow: row;
  grid-template-columns: repeat(6, 92px);
  grid-template-rows: repeat(2, 92px);
  justify-content: center;
  align-content: end;
  gap: 12px 16px;
  transform: translateX(-50%);
}

@media (max-width: 980px) {
  .stats-widgets {
    width: min(300px, calc(100vw - 32px));
  }

  .desktop-icons {
    grid-template-columns: repeat(4, 92px);
    grid-template-rows: repeat(3, 92px);
    width: min(470px, calc(100vw - 28px));
  }
}

@media (max-width: 680px) {
  .floating-actions {
    top: 12px;
    right: 12px;
    gap: 4px;
  }

  .floating-actions .icon-btn,
  .floating-actions .avatar-btn {
    width: 34px;
    height: 34px;
  }

  .stats-widgets {
    top: 68px;
    left: 12px;
    right: 12px;
    width: auto;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .server-widget,
  .stats-widgets .network-stat {
    display: none;
  }

  .stats-widgets .metric {
    min-height: 58px;
    padding: 9px;
    border-radius: 13px;
  }

  .stats-widgets .metric b {
    font-size: 15px;
  }

  .clock-block {
    top: 150px;
  }

  .desktop-icons {
    top: auto;
    left: 50%;
    bottom: 96px;
    width: min(330px, calc(100vw - 16px));
    grid-template-columns: repeat(3, 92px);
    grid-template-rows: repeat(3, 92px);
    transform: translateX(-50%);
    overflow: auto;
  }
}
