:root {
  --bg: #e9edf2;
  --grid: rgba(30, 42, 58, 0.08);
  --panel: #f8fafc;
  --panel-strong: #ffffff;
  --ink: #17202e;
  --muted: #5f6b7a;
  --soft: #d9e0e8;
  --line: #c6cfda;
  --phone-shell: #141923;
  --phone-top: #222b38;
  --blue: #316fd3;
  --green: #16876a;
  --coral: #d85d4a;
  --yellow: #c28a15;
  --shadow-low: 0 1px 2px rgba(23, 32, 46, 0.12), 0 10px 24px rgba(23, 32, 46, 0.10);
  --shadow-high: 0 8px 18px rgba(23, 32, 46, 0.16), 0 22px 56px rgba(23, 32, 46, 0.22);
  --phone-w: 390px;
  --phone-h: 760px;
}

* {
  box-sizing: border-box;
}

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

body {
  overflow: hidden;
  color: var(--ink);
  background-color: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button {
  min-width: 40px;
  min-height: 40px;
  border: 0;
  color: inherit;
  font: inherit;
}

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

.app-shell {
  display: flex;
  min-width: 320px;
  width: 100vw;
  height: 100vh;
  flex-direction: column;
  background-color: var(--bg);
}

.app-bar {
  position: relative;
  z-index: 40;
  display: flex;
  min-height: 64px;
  align-items: center;
  gap: 18px;
  padding: 10px 18px;
  background-color: rgba(248, 250, 252, 0.94);
  box-shadow: 0 1px 0 var(--line), 0 10px 28px rgba(23, 32, 46, 0.08);
  backdrop-filter: blur(14px);
}

.app-title {
  margin: 0 auto 0 0;
  color: var(--ink);
  font-size: clamp(18px, 2vw, 24px);
  font-weight: 760;
  letter-spacing: 0;
  text-wrap: balance;
}

.mode-toggle {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: var(--panel-strong);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}

.mode-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 0 14px;
  background-color: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  transition-property: color, background-color, box-shadow, transform;
  transition-duration: 160ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.mode-button:not(.is-active) {
  color: var(--muted) !important;
  background-color: transparent !important;
  box-shadow: none !important;
}

.mode-button[aria-selected="true"],
.mode-button.is-active {
  color: #ffffff !important;
  background-color: var(--blue) !important;
  box-shadow: 0 5px 16px rgba(49, 111, 211, 0.22) !important;
}

.mode-button:active {
  transform: scale(0.96);
}

.background-controls {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: var(--panel-strong);
}

.background-controls[hidden] {
  display: none;
}

.background-chip {
  display: inline-flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background-color: transparent;
  cursor: pointer;
  transition-property: background-color, box-shadow, transform;
  transition-duration: 150ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.background-chip:hover {
  background-color: rgba(23, 32, 46, 0.06);
}

.background-chip.is-active {
  background-color: rgba(23, 32, 46, 0.08);
  box-shadow: inset 0 0 0 2px var(--blue);
}

.background-chip:active {
  transform: scale(0.96);
}

.background-swatch {
  width: 24px;
  height: 24px;
  border: 1px solid rgba(23, 32, 46, 0.18);
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45);
}

.background-swatch-grid {
  background-color: #e9edf2;
  background-image:
    linear-gradient(rgba(30, 42, 58, 0.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(30, 42, 58, 0.16) 1px, transparent 1px);
  background-size: 8px 8px;
}

.background-swatch-paper {
  background-color: #f7f4ee;
  background-image: linear-gradient(rgba(80, 70, 56, 0.16) 1px, transparent 1px);
  background-size: 100% 6px;
}

.background-swatch-mint {
  background-color: #dcefe8;
  background-image:
    linear-gradient(135deg, rgba(22, 135, 106, 0.22) 25%, transparent 25%),
    linear-gradient(315deg, rgba(22, 135, 106, 0.18) 25%, transparent 25%);
  background-size: 10px 10px;
}

.background-swatch-coral {
  background-color: #f4dfd9;
  background-image:
    linear-gradient(45deg, rgba(216, 93, 74, 0.22) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(216, 93, 74, 0.18) 75%);
  background-position: 0 0, 5px 5px;
  background-size: 10px 10px;
}

.background-swatch-night {
  background-color: #17202e;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.12) 1px, transparent 1px);
  background-size: 8px 8px;
}

.desktop {
  position: relative;
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
}

.launcher {
  position: relative;
  z-index: 30;
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  overflow-x: auto;
  background-color: rgba(233, 237, 242, 0.86);
  box-shadow: 0 1px 0 var(--line);
  backdrop-filter: blur(10px);
}

.launcher-card {
  position: relative;
  display: grid;
  min-width: 156px;
  max-width: 190px;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 4px 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: var(--panel-strong);
  box-shadow: var(--shadow-low);
  cursor: pointer;
  text-align: left;
  transition-property: border-color, box-shadow, transform, background-color;
  transition-duration: 160ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.launcher-card:hover {
  border-color: var(--app-accent, var(--blue));
  background-color: #fbfcfe;
  box-shadow: 0 1px 2px rgba(23, 32, 46, 0.10), 0 14px 30px rgba(23, 32, 46, 0.14);
}

.launcher-card:active {
  transform: scale(0.96);
}

.launcher-dot {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background-color: var(--app-accent, var(--blue));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.launcher-card-name,
.launcher-card-meta,
.phone-name,
.tray-button span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.launcher-card-name {
  color: var(--ink);
  font-size: 14px;
  font-weight: 760;
}

.launcher-card-meta {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  position: relative;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.workspace.playful {
  display: block;
}

.workspace.playful.background-grid {
  background-color: #e9edf2;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
}

.workspace.playful.background-paper {
  background-color: #f7f4ee;
  background-image:
    linear-gradient(rgba(80, 70, 56, 0.10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(80, 70, 56, 0.05) 1px, transparent 1px);
  background-size: 100% 28px, 28px 100%;
}

.workspace.playful.background-mint {
  background-color: #dcefe8;
  background-image:
    linear-gradient(135deg, rgba(22, 135, 106, 0.10) 25%, transparent 25%),
    linear-gradient(315deg, rgba(22, 135, 106, 0.08) 25%, transparent 25%);
  background-position: 0 0, 16px 16px;
  background-size: 32px 32px;
}

.workspace.playful.background-coral {
  background-color: #f4dfd9;
  background-image:
    linear-gradient(45deg, rgba(216, 93, 74, 0.11) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(216, 93, 74, 0.10) 75%);
  background-position: 0 0, 16px 16px;
  background-size: 32px 32px;
}

.workspace.playful.background-night {
  background-color: #17202e;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 32px 32px;
}

.workspace.playful.background-night .empty-state {
  color: rgba(255, 255, 255, 0.68);
}

.workspace.cockpit {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  gap: 18px;
  align-content: start;
  overflow: auto;
  padding: 18px;
}

.phone-window {
  display: flex;
  width: min(var(--window-w, var(--phone-w)), calc(100vw - 36px));
  height: min(var(--window-h, var(--phone-h)), calc(100vh - 176px));
  min-height: 520px;
  flex-direction: column;
  border-radius: 8px;
  background-color: var(--panel-strong);
  box-shadow: var(--shadow-high);
  outline: 1px solid rgba(23, 32, 46, 0.14);
  overflow: hidden;
  transition-property: box-shadow, outline-color, transform;
  transition-duration: 160ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.workspace.playful .phone-window {
  position: absolute;
}

.workspace.cockpit .phone-window {
  position: static;
  width: min(100%, var(--window-w, var(--phone-w)));
  height: min(var(--window-h, var(--phone-h)), 76vh);
  justify-self: center;
}

.phone-window.is-focused {
  outline-color: var(--app-accent, var(--blue));
  box-shadow: 0 10px 22px rgba(23, 32, 46, 0.18), 0 26px 68px rgba(23, 32, 46, 0.28);
}

.phone-titlebar {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 14px;
  color: #ffffff;
  background-color: var(--phone-top);
  user-select: none;
}

.workspace.playful .phone-titlebar {
  cursor: grab;
}

.workspace.playful .phone-titlebar:active {
  cursor: grabbing;
}

.phone-name {
  margin-right: auto;
  font-size: 13px;
  font-weight: 760;
}

.window-actions {
  display: inline-flex;
  gap: 4px;
}

.cockpit-actions {
  display: none;
  gap: 4px;
}

.workspace.cockpit .cockpit-actions {
  display: inline-flex;
}

.cockpit-button {
  font-size: 14px;
  font-weight: 760;
}

.size-button {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.12);
  font-size: 12px;
}

.icon-button {
  display: inline-flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background-color: transparent;
  color: rgba(255, 255, 255, 0.76);
  cursor: pointer;
  font-size: 16px;
  transition-property: color, background-color, transform;
  transition-duration: 150ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.icon-button:hover {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.12);
}

.icon-button.is-danger:hover {
  background-color: var(--coral);
}

.icon-button:active {
  transform: scale(0.96);
}

.phone-frame {
  display: flex;
  min-height: 0;
  flex: 1;
  padding: 12px;
  background-color: var(--phone-shell);
}

.phone-screen {
  position: relative;
  flex: 1;
  overflow: hidden;
  border-radius: 28px;
  background-color: #ffffff;
  box-shadow: inset 0 0 0 7px #070a0f, inset 0 0 0 8px rgba(255, 255, 255, 0.10);
}

.phone-screen::before {
  position: absolute;
  top: 7px;
  left: 50%;
  z-index: 2;
  width: 88px;
  height: 20px;
  border-radius: 0 0 13px 13px;
  background-color: #070a0f;
  content: "";
  transform: translateX(-50%);
}

.phone-screen iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background-color: #ffffff;
}

.minimized-tray {
  position: relative;
  z-index: 35;
  display: none;
  min-height: 58px;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  overflow-x: auto;
  background-color: rgba(248, 250, 252, 0.96);
  box-shadow: 0 -1px 0 var(--line), 0 -12px 30px rgba(23, 32, 46, 0.08);
}

.minimized-tray.has-items {
  display: flex;
}

.tray-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0;
  white-space: nowrap;
}

.tray-button {
  display: inline-flex;
  max-width: 180px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background-color: var(--panel-strong);
  box-shadow: var(--shadow-low);
  cursor: pointer;
  font-size: 13px;
  font-weight: 720;
  transition-property: border-color, background-color, transform;
  transition-duration: 150ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.tray-button::before {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background-color: var(--app-accent, var(--green));
  content: "";
}

.tray-button:hover {
  border-color: var(--app-accent, var(--blue));
}

.tray-button:active {
  transform: scale(0.96);
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 680;
  pointer-events: none;
  text-align: center;
}

@media (max-width: 740px) {
  .app-bar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .mode-toggle {
    width: 100%;
  }

  .background-controls {
    width: 100%;
    overflow-x: auto;
  }

  .mode-button {
    flex: 1;
    padding-inline: 8px;
  }

  .launcher {
    padding: 10px;
  }

  .launcher-card {
    min-width: 136px;
  }

  .workspace.playful,
  .workspace.cockpit {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    overflow: auto;
    padding: 12px;
  }

  .workspace.playful .phone-window,
  .workspace.cockpit .phone-window {
    position: static;
    width: min(100%, var(--window-w, var(--phone-w)));
    height: min(var(--window-h, var(--phone-h)), 72vh);
    justify-self: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mode-button,
  .background-chip,
  .launcher-card,
  .phone-window,
  .icon-button,
  .tray-button {
    transition-property: none;
  }
}
