/* Wanos — macOS 26/27 desktop look: menu bar, Dock, ⌘Tab, Liquid Glass */

:root {
  color-scheme: dark;

  /* System font: SF Pro on Apple devices */
  --font: -apple-system, BlinkMacSystemFont, system-ui, "SF Pro Text", "SF Pro Display", "Helvetica Neue", sans-serif;
  --font-rounded: ui-rounded, -apple-system, "SF Pro Rounded", system-ui, sans-serif;

  /* macOS dark system colors */
  --label: rgba(255, 255, 255, 0.95);
  --label-secondary: rgba(235, 235, 245, 0.66);
  --label-tertiary: rgba(235, 235, 245, 0.38);
  --accent: #0a84ff;
  --green: #30d158;
  --orange: #ff9f0a;

  /* Liquid Glass: very clear fill, strong blur + saturation, bright rim */
  --glass-fill: linear-gradient(180deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0.05) 100%);
  --glass-tint: rgba(18, 20, 28, 0.18);
  --glass-blur: blur(22px) saturate(210%) brightness(1.08);
  --glass-rim: linear-gradient(140deg,
      rgba(255, 255, 255, 0.95) 0%,
      rgba(255, 255, 255, 0.28) 22%,
      rgba(255, 255, 255, 0.06) 48%,
      rgba(255, 255, 255, 0.22) 78%,
      rgba(255, 255, 255, 0.75) 100%);
  --glass-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.55),
    inset 0 -1px 1px rgba(255, 255, 255, 0.12),
    inset 0 0 18px rgba(255, 255, 255, 0.08),
    0 18px 40px rgba(0, 0, 0, 0.35),
    0 2px 8px rgba(0, 0, 0, 0.18);
  --hover-fill: rgba(255, 255, 255, 0.16);
  --press-fill: rgba(255, 255, 255, 0.26);

  /* Desktop wallpaper (Tahoe-like dusk gradient) so the glass has color to refract */
  --wallpaper:
    radial-gradient(70% 60% at 18% 18%, #3d6fd8 0%, transparent 60%),
    radial-gradient(60% 55% at 85% 15%, #c04fa8 0%, transparent 60%),
    radial-gradient(70% 60% at 70% 90%, #f08a4b 0%, transparent 60%),
    radial-gradient(60% 60% at 10% 95%, #1aa39a 0%, transparent 60%),
    linear-gradient(180deg, #1d2140 0%, #2a1838 100%);

  --menubar-h: 30px;
  --dock-icon: 52px;
  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--wallpaper);
  background-attachment: fixed;
  color: var(--label);
  font-family: var(--font);
  font-size: 13px;
  letter-spacing: -0.08px;
  -webkit-font-smoothing: antialiased;
  touch-action: none;
}

button {
  font-family: inherit;
  color: inherit;
  border: none;
  background: none;
  cursor: pointer;
}

.sym {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.hidden {
  display: none !important;
}

/* ---------- Liquid Glass material ---------- */
.glass,
.glass-bar {
  position: relative;
  background: var(--glass-fill), var(--glass-tint);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  isolation: isolate;
}

/* Bright, uneven rim: light catching the curved edge */
.glass::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: var(--glass-rim);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  /* Behind the content: icons that grow or bounce out of the Dock pass in front of the rim */
  z-index: -1;
}

/* Specular gloss: a soft lens of light across the top */
.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(120% 70% at 30% -10%, rgba(255, 255, 255, 0.34) 0%, rgba(255, 255, 255, 0.08) 45%, transparent 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.10) 0%, transparent 50%);
  pointer-events: none;
  z-index: -1;
}

/* ---------- Menu bar ---------- */
#menubar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--menubar-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) calc(env(safe-area-inset-right, 0px) + 10px) 0 calc(env(safe-area-inset-left, 0px) + 10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 150;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.14) 0%, rgba(255, 255, 255, 0.06) 100%), rgba(16, 18, 26, 0.22);
  box-shadow: inset 0 -0.5px 0 rgba(255, 255, 255, 0.18), 0 1px 12px rgba(0, 0, 0, 0.18);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.menubar-left,
.menubar-right {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 100%;
  min-width: 0;
}

.menu-item,
.menu-extra {
  height: 24px;
  padding: 0 9px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.12s ease;
}

.menu-item:active,
button.menu-extra:active,
.menu-item.open {
  background: var(--press-fill);
}

.menu-item.logo .sym {
  width: 18px;
  height: 18px;
}

.menu-item.app-name {
  font-weight: 700;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-extra .sym {
  width: 16px;
  height: 16px;
}

.status {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--label-secondary);
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

.status-dot.connecting {
  background: var(--orange);
  box-shadow: 0 0 6px var(--orange);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  50% { opacity: 0.35; }
}

.clock {
  font-variant-numeric: tabular-nums;
}

/* ---------- Workspace ---------- */
#workspace {
  position: absolute;
  top: calc(var(--menubar-h) + env(safe-area-inset-top, 0px));
  bottom: calc(var(--dock-icon) + 34px + env(safe-area-inset-bottom, 0px));
  left: env(safe-area-inset-left, 0px);
  right: env(safe-area-inset-right, 0px);
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#canvas-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The streamed Mac window, with the macOS window shadow */
#viewport {
  max-width: 100%;
  max-height: 100%;
  border-radius: 16px;
  box-shadow:
    0 0 0 0.5px rgba(255, 255, 255, 0.22),
    0 30px 70px rgba(0, 0, 0, 0.55),
    0 10px 24px rgba(0, 0, 0, 0.3);
  display: none;
}

#viewport.active {
  display: block;
}

/* ---------- Empty state: macOS alert ---------- */
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.dialog {
  width: 290px;
  max-width: 100%;
  padding: 24px 18px 16px;
  border-radius: 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.dialog-icon svg {
  width: 68px;
  height: 68px;
  filter: drop-shadow(0 10px 22px rgba(120, 100, 240, 0.35));
  margin-bottom: 14px;
}

.dialog h2 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
  margin-bottom: 6px;
}

.dialog p {
  font-size: 12px;
  line-height: 1.4;
  color: var(--label-secondary);
  margin-bottom: 18px;
}

/* Prominent capsule button with glossy top highlight */
.btn-prominent {
  position: relative;
  width: 100%;
  height: 34px;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0) 51%),
    linear-gradient(180deg, #3aa0ff 0%, #0a6cff 100%);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    inset 0 0 0 0.5px rgba(255, 255, 255, 0.35),
    0 1px 2px rgba(0, 0, 0, 0.25),
    0 6px 18px rgba(10, 132, 255, 0.45);
  transition: transform 0.25s var(--ease-spring), filter 0.15s ease;
}

.btn-prominent:active {
  transform: scale(0.97);
  filter: brightness(0.92);
}

/* ---------- Dock ---------- */
#dock-area {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
  transform: translateX(-50%);
  max-width: calc(100% - 16px);
  z-index: 140;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.dock {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 6px 8px;
  border-radius: 24px;
  max-width: 100%;
  /* Icons magnify and bounce above the Dock, so nothing may clip them */
  overflow: visible;
  pointer-events: auto;
}

.dock-apps,
.dock-keys {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dock-item {
  --mag: 1;
  position: relative;
  flex: 0 0 auto;
  width: calc(var(--dock-icon) * var(--mag));
  height: calc(var(--dock-icon) + 8px);
  transition: width 0.12s ease-out;
}

/* Bounce lives on the wrapper so it combines with magnification on the icon */
.dock-icon-wrap {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
}

.dock-icon-wrap.bouncing {
  animation: dock-bounce 0.95s cubic-bezier(0.28, 0.84, 0.42, 1);
}

@keyframes dock-bounce {
  0%   { transform: translate(-50%, 0); }
  22%  { transform: translate(-50%, -30px); }
  44%  { transform: translate(-50%, 0); }
  60%  { transform: translate(-50%, -14px); }
  76%  { transform: translate(-50%, 0); }
  88%  { transform: translate(-50%, -4px); }
  100% { transform: translate(-50%, 0); }
}

.dock-item img,
.dock-item .placeholder {
  display: block;
  width: calc(var(--dock-icon) * var(--mag));
  height: calc(var(--dock-icon) * var(--mag));
  object-fit: contain;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
  transition: width 0.12s ease-out, height 0.12s ease-out, filter 0.1s ease;
}

.dock-item .placeholder {
  font-size: calc(var(--dock-icon) * var(--mag) * 0.45);
}

/* macOS darkens an icon while it is held down */
.dock-item:active img,
.dock-item:active .placeholder,
.dock-item.pressed img,
.dock-item.pressed .placeholder {
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3)) brightness(0.55);
}

/* Running-app indicator dot, like the real Dock: tiny, dim for open apps, bright for the active one */
.dock-item::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 1px;
  width: 3px;
  height: 3px;
  margin-left: -1.5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
}

.dock-item.current::after {
  background: #fff;
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.95), 0 0 8px rgba(255, 255, 255, 0.5);
}

/* App name bubble above an icon while pressed */
.dock-item .dock-label {
  position: absolute;
  bottom: calc(var(--dock-icon) * var(--mag) + 20px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  white-space: nowrap;
  background: rgba(40, 42, 50, 0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.25), 0 4px 12px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.dock-item:hover .dock-label,
.dock-item:active .dock-label {
  opacity: 1;
}

.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 23%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0) 50%),
    linear-gradient(180deg, #9a9aa2 0%, #4a4a52 100%);
  color: #fff;
  font-family: var(--font-rounded);
  font-weight: 700;
  font-size: calc(var(--dock-icon) * 0.45);
}

.dock-divider {
  flex: 0 0 auto;
  align-self: stretch;
  width: 1px;
  margin: 6px 6px 10px;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.45), transparent);
}

.dock-key {
  flex: 0 0 auto;
  min-width: 38px;
  height: 38px;
  padding: 0 8px;
  margin-bottom: 11px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 500;
  color: var(--label);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), inset 0 0 0 0.5px rgba(255, 255, 255, 0.14);
  transition: background 0.15s ease, color 0.15s ease, transform 0.25s var(--ease-spring);
}

.dock-key.text {
  font-size: 12px;
  font-weight: 600;
  color: var(--label-secondary);
}

.dock-key:active {
  background: var(--press-fill);
  transform: scale(0.92);
}

/* Latched modifier: glowing accent glass */
.dock-key.active {
  color: #fff;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0) 55%), var(--accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 0 14px rgba(10, 132, 255, 0.6);
}

/* Window list that pops up above a Dock icon */
.dock-menu {
  position: absolute;
  /* Clears an icon that is magnified or bouncing above the Dock */
  bottom: calc(100% + 24px);
  transform: translateX(-50%);
  min-width: 220px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 6px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
}

/* The pointer is part of the menu's own shape (clip-path set in app.js), so
   glass, tint and rim run around it in one piece. Its height is reserved as
   extra bottom padding. */
.dock-menu {
  bottom: calc(100% + 20px);
  padding-bottom: 15px;
  box-shadow: none;
  filter: none;
}

.dock-menu::after {
  display: none;
}

.dock-menu .menu-outline {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: -1;
}

/* Twice the visible width: the clip keeps only the inner half */
.dock-menu .menu-outline path {
  fill: none;
  stroke: url(#dock-menu-rim);
  stroke-width: 2;
}

/* Hide the name bubble while the icon's window list is open */
.dock.menu-open .dock-label {
  display: none;
}

.dock-menu button {
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dock-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1;
}

.dock-menu .win-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dock-menu .win-note {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--label-tertiary);
}

.dock-menu button.current .win-note,
.dock-menu button:active .win-note,
.dock-menu button:hover .win-note {
  color: rgba(255, 255, 255, 0.75);
}

@media (hover: hover) {
  .dock-menu button:hover {
    background: var(--accent);
    color: #fff;
  }
}

.dock-menu button:active,
.dock-menu button.current {
  background: var(--accent);
  color: #fff;
}

.dock-menu .menu-title {
  padding: 4px 10px 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--label-secondary);
}

.dock-menu .menu-sep {
  height: 1px;
  margin: 4px 8px;
  background: rgba(255, 255, 255, 0.15);
}

/* ---------- macOS Lock Screen Overlay ---------- */
.lockscreen-backdrop {
  z-index: 300;
  background: rgba(10, 12, 18, 0.65);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
}

.lockscreen-card {
  width: 100%;
  max-width: 360px;
  padding: 32px 28px 28px;
  border-radius: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), inset 0 1px 1px rgba(255, 255, 255, 0.4);
  transform: scale(1);
  transition: transform 0.3s var(--ease-spring);
}

.modal-backdrop.hidden .lockscreen-card {
  transform: scale(0.92);
}

/* Multi-user account selector row */
.lockscreen-users-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 20px;
  width: 100%;
  padding: 4px 6px;
}

.lockscreen-user-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: var(--label-secondary);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s;
  opacity: 0.6;
}

.lockscreen-user-item:hover {
  opacity: 0.95;
  transform: translateY(-2px);
}

.lockscreen-user-item.active {
  opacity: 1;
  transform: scale(1.08);
}

.lockscreen-thumb {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(255,255,255,0.22), rgba(255,255,255,0.06));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  border: 2px solid transparent;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.lockscreen-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.lockscreen-user-item.active .lockscreen-thumb {
  border-color: #0a84ff;
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.45), 0 6px 16px rgba(10, 132, 255, 0.4);
}

.lockscreen-user-name {
  font-size: 11px;
  font-weight: 500;
  max-width: 76px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: rgba(255, 255, 255, 0.7);
}

.lockscreen-user-item.active .lockscreen-user-name {
  color: #fff;
  font-weight: 600;
}

/* Focused account avatar */
.lockscreen-avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, #0a84ff, #5e5ce6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 32px;
  font-weight: 600;
  margin-bottom: 14px;
  box-shadow: 0 8px 24px rgba(10, 132, 255, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.5);
  position: relative;
}

.lockscreen-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.lockscreen-card h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--label);
  margin-bottom: 4px;
}

.lockscreen-status {
  font-size: 13px;
  color: var(--label-secondary);
  margin-bottom: 20px;
}

.lockscreen-input-row {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 22px;
  padding: 4px 6px 4px 14px;
  transition: all 0.2s ease;
}

.lockscreen-input-row:focus-within {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.18);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.3);
}

.lockscreen-input-row input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 0.2px;
}

.lockscreen-input-row input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.lockscreen-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  transition: background 0.15s, transform 0.1s;
}

.lockscreen-btn:hover {
  background: rgba(255, 255, 255, 0.35);
}

.lockscreen-btn:active {
  transform: scale(0.92);
}

.lockscreen-error {
  color: #ff453a;
  font-size: 12px;
  margin-top: 10px;
  font-weight: 500;
}

@keyframes lock-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.lockscreen-card.shake {
  animation: lock-shake 0.4s ease;
}

/* ---------- App Switcher (⌘Tab) ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  background: rgba(0, 0, 0, 0.08);
  opacity: 1;
  transition: opacity 0.16s ease;
}

.modal-backdrop.hidden {
  display: flex !important;
  opacity: 0;
  pointer-events: none;
}

.switcher-wrap {
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.switcher {
  max-width: 100%;
  padding: 18px;
  border-radius: 34px;
  transform: scale(1);
  transition: transform 0.3s var(--ease-spring);
}

.modal-backdrop.hidden .switcher {
  transform: scale(0.94);
}

.switcher-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  touch-action: pan-x;
}

.switcher-row::-webkit-scrollbar {
  display: none;
}

.switcher-item {
  position: relative;
  flex: 0 0 auto;
  width: 132px;
  padding: 14px 10px 10px;
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: background 0.12s ease;
}

/* Selected app: frosted rounded square behind the icon, name underneath */
.switcher-item.selected {
  background: rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 0 0 0.5px rgba(255, 255, 255, 0.3);
}

.switcher-icon {
  width: 104px;
  height: 104px;
  object-fit: contain;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.35));
  transition: transform 0.25s var(--ease-spring);
}

.switcher-icon.placeholder {
  width: 90px;
  height: 90px;
  margin: 7px;
  font-size: 40px;
}

.switcher-item:active .switcher-icon {
  transform: scale(0.92);
}

.switcher-name {
  width: 100%;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  visibility: hidden;
}

.switcher-item.selected .switcher-name {
  visibility: visible;
}

.switcher-badge {
  position: absolute;
  top: 8px;
  right: 14px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.switcher-empty {
  padding: 26px 36px;
  color: var(--label-secondary);
  font-size: 13px;
}

/* Windows of the selected app, as glass chips under the switcher */
.switcher-windows {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 100%;
}

.window-chip {
  position: relative;
  height: 32px;
  max-width: 300px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.window-chip.current {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0) 55%), var(--accent);
  color: #fff;
}

.window-chip .chip-note {
  margin-left: 6px;
  color: var(--label-tertiary);
  font-size: 11px;
}

#hidden-input {
  position: absolute;
  top: -1000px;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 820px) {
  :root { --dock-icon: 44px; }
  .status, #btn-menu-keyboard, .clock { display: none; }
  .switcher-item { width: 104px; }
  .switcher-icon { width: 78px; height: 78px; }
  .switcher-icon.placeholder { width: 68px; height: 68px; font-size: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Safari full screen puts its own round ✕ button over the top-left corner.
   Make the menu bar tall enough to hold it and leave it a slot on the left. */
body.is-fullscreen {
  --menubar-h: 46px;
}

body.is-fullscreen #menubar {
  padding-left: calc(env(safe-area-inset-left, 0px) + 72px);
}

/* ---------- Auto-hide (like the macOS Dock and full-screen menu bar) ---------- */
#menubar,
#dock-area {
  transition: transform 0.35s var(--ease-spring), opacity 0.25s ease;
}

#workspace {
  transition: top 0.35s var(--ease-spring), bottom 0.35s var(--ease-spring);
}

body.autohide #workspace {
  top: env(safe-area-inset-top, 0px);
  bottom: env(safe-area-inset-bottom, 0px);
}

body.autohide #menubar {
  transform: translateY(-100%);
  opacity: 0;
}

body.autohide #dock-area {
  transform: translate(-50%, calc(100% + 16px));
  opacity: 0;
}

body.autohide.show-top #menubar {
  transform: none;
  opacity: 1;
}

body.autohide.show-bottom #dock-area {
  transform: translateX(-50%);
  opacity: 1;
}

.edge-zone {
  position: fixed;
  left: 0;
  right: 0;
  height: 14px;
  z-index: 130;
  display: none;
}

.edge-zone.top {
  top: 0;
}

.edge-zone.bottom {
  bottom: 0;
}

body.autohide .edge-zone {
  display: block;
}

/* ---------- Menu bar menus ---------- */
#status-pill {
  cursor: default;
}

/* Status text appears only for problems (connecting, errors); a healthy stream shows just the dot */
#fps-counter:empty {
  display: none;
}

.menu-dropdown {
  position: fixed;
  z-index: 200;
  min-width: 232px;
  max-width: min(420px, calc(100vw - 16px));
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  --glass-tint: rgba(28, 30, 40, 0.52);
  font-size: 13px;
  animation: menu-in 0.14s ease-out;
}

.menu-scroll {
  flex: 1 1 auto;
  min-height: 0;
  padding: 5px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-3px); }
}

.menu-row {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 26px;
  padding: 3px 10px 3px 4px;
  border-radius: 6px;
  color: var(--label);
  cursor: default;
}

.menu-row.focused,
.menu-row:active {
  background: var(--accent);
  color: #fff;
}

.menu-row.blink {
  animation: menu-blink 0.11s steps(2) 1;
}

@keyframes menu-blink {
  50% { background: transparent; color: var(--label); }
}

.menu-row.disabled {
  color: var(--label-tertiary);
}

.menu-row.danger:not(.focused) .menu-label-text {
  color: #ff6961;
}

.menu-check {
  width: 18px;
  flex: 0 0 18px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
}

.menu-label {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.menu-label-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-note {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--label-tertiary);
}

.menu-row.focused .menu-note {
  color: rgba(255, 255, 255, 0.75);
}

.menu-shortcut {
  margin-left: 24px;
  color: var(--label-tertiary);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.menu-row.focused .menu-shortcut {
  color: rgba(255, 255, 255, 0.85);
}

.menu-sep {
  height: 1px;
  margin: 5px 10px;
  background: rgba(255, 255, 255, 0.14);
}

.menu-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px 3px 22px;
  font-size: 11px;
  font-weight: 600;
  color: var(--label-secondary);
}

.menu-header-icon {
  width: 16px;
  height: 16px;
  margin-left: -18px;
  border-radius: 4px;
  font-size: 9px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  z-index: 250;
  top: calc(var(--menubar-h) + env(safe-area-inset-top, 0px) + 12px);
  left: 50%;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  transform: translate(-50%, -8px);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.3s var(--ease-spring);
  pointer-events: none;
}

.toast.visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

/* ---------- Secondary glass button ---------- */
.btn-glass {
  height: 28px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--label);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0.08) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 0 0 0.5px rgba(255, 255, 255, 0.25), 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.25s var(--ease-spring), background 0.15s ease;
}

.btn-glass:active {
  transform: scale(0.96);
  background: var(--press-fill);
}

.btn-glass:disabled {
  opacity: 0.4;
}

.btn-glass.danger {
  color: #ff6961;
}

.btn-prominent.destructive {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0.06) 50%, rgba(255, 255, 255, 0) 51%),
    linear-gradient(180deg, #ff6b61 0%, #e5281c 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 0 0 0.5px rgba(255, 255, 255, 0.3),
    0 1px 2px rgba(0, 0, 0, 0.25),
    0 6px 18px rgba(255, 69, 58, 0.4);
}

/* ---------- Alert ---------- */
.alert-backdrop {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade-in 0.15s ease-out;
}

@keyframes fade-in {
  from { opacity: 0; }
}

.alert {
  width: 272px;
  padding: 20px 16px 16px;
  border-radius: 22px;
  text-align: center;
  --glass-tint: rgba(30, 32, 42, 0.6);
  animation: pop-in 0.3s var(--ease-spring);
}

@keyframes pop-in {
  from { transform: scale(1.08); opacity: 0; }
}

.alert-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 10px;
  display: block;
  font-size: 24px;
}

.alert h3 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
}

.alert p {
  font-size: 12px;
  line-height: 1.4;
  color: var(--label-secondary);
  margin-bottom: 16px;
}

.alert-buttons {
  display: flex;
  gap: 8px;
}

.alert-buttons > * {
  flex: 1;
  height: 30px;
}

/* ---------- Settings window ---------- */
.settings-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--menubar-h) + env(safe-area-inset-top, 0px) + 16px) 16px 16px;
  background: rgba(0, 0, 0, 0.18);
  animation: fade-in 0.18s ease-out;
}

.settings-window {
  display: flex;
  width: min(760px, 100%);
  height: min(560px, 100%);
  border-radius: 24px;
  overflow: hidden;
  --glass-tint: rgba(24, 26, 36, 0.62);
  animation: pop-in 0.35s var(--ease-spring);
}

.settings-side {
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  padding: 14px 10px;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset -0.5px 0 0 rgba(255, 255, 255, 0.12);
}

.traffic-lights {
  display: flex;
  gap: 8px;
  padding: 2px 6px 16px;
}

.tl {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.2);
}

.tl.close {
  position: relative;
  background: #ff5f57;
}

/* Bigger touch target than the 12 pt light */
.tl.close::before {
  content: "";
  position: absolute;
  inset: -12px;
}

.settings-sidebar {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.side-item {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 32px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 13px;
  text-align: left;
  color: var(--label);
}

.side-item.selected {
  background: var(--accent);
  color: #fff;
}

.side-item:active:not(.selected) {
  background: var(--hover-fill);
}

.pane-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0) 60%),
    var(--tile);
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.3), 0 1px 2px rgba(0, 0, 0, 0.25);
}

.pane-icon .sym {
  width: 14px;
  height: 14px;
}

.settings-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.settings-title {
  flex: 0 0 auto;
  padding: 16px 24px 10px;
  font-size: 15px;
  font-weight: 700;
}

.settings-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 24px 24px;
  -webkit-overflow-scrolling: touch;
}

.set-group {
  margin-top: 14px;
}

.set-group h4 {
  padding: 0 4px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--label-secondary);
}

.set-box {
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.1);
}

.set-row {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 44px;
  padding: 8px 14px;
}

.set-row + .set-row {
  box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.1);
}

.set-label {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}

.set-label small {
  font-size: 11px;
  line-height: 1.35;
  color: var(--label-tertiary);
}

.set-control {
  flex: 0 1 auto;
  min-width: 0;
  display: flex;
  justify-content: flex-end;
}

.set-value {
  font-size: 13px;
  color: var(--label-secondary);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 300px;
}

.set-foot {
  padding: 6px 4px 0;
  font-size: 11px;
  color: var(--label-tertiary);
}

/* Segmented control */
.segmented {
  display: flex;
  padding: 2px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.25);
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.1);
}

.seg {
  height: 26px;
  padding: 0 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  color: var(--label-secondary);
  white-space: nowrap;
  transition: background 0.2s ease, color 0.2s ease;
}

.seg.on {
  color: var(--label);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.14) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 1px 3px rgba(0, 0, 0, 0.3);
}

.seg:disabled {
  opacity: 0.35;
}

/* Switch */
.switch {
  position: relative;
  width: 38px;
  height: 22px;
  flex: 0 0 38px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.15);
  transition: background 0.25s ease;
}

.switch.on {
  background: var(--accent);
}

.switch .knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(180deg, #fff 0%, #e8e8ee 100%);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: transform 0.3s var(--ease-spring);
}

.switch.on .knob {
  transform: translateX(16px);
}

/* Slider */
.slider {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slider-end {
  font-size: 11px;
  color: var(--label-tertiary);
}

.slider-value {
  min-width: 46px;
  text-align: right;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--label-secondary);
}

.slider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 170px;
  height: 22px;
  background: transparent;
}

.slider input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent) 0 var(--fill, 50%), rgba(255, 255, 255, 0.18) var(--fill, 50%) 100%);
}

.slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -8px;
  border-radius: 50%;
  background: linear-gradient(180deg, #fff 0%, #e8e8ee 100%);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4), inset 0 0 0 0.5px rgba(0, 0, 0, 0.1);
}

/* About */
.about-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 0 4px;
}

.about-icon svg {
  width: 72px;
  height: 72px;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35));
}

.about-hero h2 {
  font-size: 20px;
  font-weight: 700;
}

.about-hero p {
  font-size: 12px;
  color: var(--label-secondary);
}

/* Narrow (portrait iPad mini): sidebar becomes a top strip */
@media (max-width: 640px) {
  .settings-window {
    flex-direction: column;
  }
  .settings-side {
    flex: 0 0 auto;
    padding-bottom: 6px;
  }
  .settings-sidebar {
    flex-direction: row;
    overflow-x: auto;
  }
  .side-item span:last-child {
    white-space: nowrap;
  }
  .slider input[type="range"] {
    width: 110px;
  }
}

/* Dock without shortcut keys */
body.no-dock-keys .dock-keys,
body.no-dock-keys .dock-divider {
  display: none;
}

/* ---------- Liquid Glass (clear, refracting) ----------
   liquid-glass.js draws the Mac window through a lens under every glass panel.
   Here the panels drop the heavy frost so that refraction shows through:
   a whisper of blur for legibility, a light tint, and a fine rim. */
#glass-layer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  pointer-events: none;
}

body.liquid {
  --glass-fill: linear-gradient(180deg, rgba(255, 255, 255, 0.10) 0%, rgba(255, 255, 255, 0.02) 100%);
  --glass-tint: rgba(12, 14, 20, 0.06);
  --glass-blur: blur(0.6px) saturate(150%);
  --glass-rim: linear-gradient(140deg,
      rgba(255, 255, 255, 0.7) 0%,
      rgba(255, 255, 255, 0.12) 25%,
      rgba(255, 255, 255, 0.02) 50%,
      rgba(255, 255, 255, 0.10) 75%,
      rgba(255, 255, 255, 0.45) 100%);
  --glass-shadow:
    inset 0 1px 0.5px rgba(255, 255, 255, 0.35),
    inset 0 -0.5px 0.5px rgba(255, 255, 255, 0.10),
    0 10px 30px rgba(0, 0, 0, 0.28),
    0 1px 4px rgba(0, 0, 0, 0.16);
}

body.liquid #menubar {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 100%), rgba(12, 14, 20, 0.12);
  backdrop-filter: blur(0.6px) saturate(150%);
  -webkit-backdrop-filter: blur(0.6px) saturate(150%);
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.55), 0 1px 2px rgba(0, 0, 0, 0.45);
}

/* The specular lens drawn in CSS would double the shader's highlight */
body.liquid .glass::before {
  opacity: 0.35;
}

/* Text panels keep some frost on top of the refraction so labels stay readable */
body.liquid .menu-dropdown,
body.liquid .dock-menu,
body.liquid .settings-window,
body.liquid .alert,
body.liquid .switcher {
  --glass-blur: blur(4px) saturate(170%);
  --glass-tint: rgba(16, 18, 26, 0.4);
}

body.liquid .dock {
  --glass-blur: blur(2.5px) saturate(160%);
  --glass-tint: rgba(16, 18, 26, 0.14);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
