:root {
  --bg: #f3efe6;
  --bg2: #e6dccb;
  --panel: #fffaf1;
  --ink: #2a2620;
  --muted: #6a5f52;
  --accent: #d26d35;
  --accent-dark: #b45725;
  --border: #cdb9a4;
  --shadow: rgba(40, 32, 24, 0.12);
  --mono: "Cascadia Code", "Fira Code", "Consolas", monospace;
  --sans: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 15% -10%, #fff8ec 0%, var(--bg) 45%, var(--bg2) 100%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 0, rgba(255, 255, 255, 0.15) 1px, transparent 1px, transparent 12px);
  min-height: 100vh;
}

body.launcher-page {
  background: #000;
  color: #e6e6e6;
  overflow: hidden;
}

#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

body.launcher-page #app {
  max-width: none;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

.launcher-app {
  position: relative;
  min-height: 100vh;
}

.launcher-toolbar {
  position: fixed;
  top: 12px;
  left: 50%;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-10px);
  transition: opacity 160ms ease, transform 160ms ease;
  max-width: calc(100vw - 40px);
}

.launcher-status {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.68);
  color: rgba(235, 235, 235, 0.92);
  font-family: var(--mono);
  font-size: 12px;
  backdrop-filter: blur(8px);
}

.launcher-action {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(12, 12, 12, 0.88);
  color: #f3f3f3;
}

.launcher-workspace {
  min-height: 100vh;
  height: 100vh;
  border: none;
  background: #000;
  box-shadow: none;
}

.launcher-workspace::before {
  display: none;
}

.launcher-workspace.workspace-drop-target {
  box-shadow:
    inset 0 0 0 2px rgba(255, 212, 96, 0.72),
    inset 0 0 0 10px rgba(255, 255, 255, 0.06);
}

.launcher-workspace .workspace-empty {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.46);
  color: rgba(241, 241, 241, 0.78);
  backdrop-filter: blur(6px);
}

.launcher-session-info {
  position: fixed;
  top: 56px;
  left: 50%;
  z-index: 60;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.62);
  color: rgba(231, 231, 231, 0.85);
  font-family: var(--mono);
  font-size: 12px;
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-10px);
  transition: opacity 160ms ease, transform 160ms ease;
  max-width: calc(100vw - 40px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.launcher-page.launcher-overlays-visible .launcher-toolbar,
body.launcher-page.launcher-overlays-visible .launcher-session-info {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.launcher-hidden-ui {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

body.storage-page {
  overflow-x: hidden;
  overflow-y: auto;
  background:
    radial-gradient(1200px 600px at 15% -10%, #fff8ec 0%, var(--bg) 45%, var(--bg2) 100%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 0, rgba(255, 255, 255, 0.15) 1px, transparent 1px, transparent 12px);
}

body.storage-page #app {
  max-width: none;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

.storage-app {
  position: relative;
  min-height: 100vh;
}

.storage-screen-panel {
  position: absolute;
  inset: 0;
  z-index: auto;
  pointer-events: none;
  background: transparent;
}

body.storage-page .storage-workspace {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  border: none;
  box-shadow: none;
  overflow: visible;
  background: transparent !important;
  pointer-events: none;
}

body.storage-page .storage-workspace::before {
  display: none !important;
}

body.storage-page .storage-workspace .workspace-empty {
  display: none;
}

.storage-overlay {
  position: relative;
  padding: 24px 24px 56px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  pointer-events: none;
}

.storage-overlay > * {
  position: relative;
  z-index: 10;
  width: min(1320px, 100%);
  margin: 0 auto;
  pointer-events: auto;
}

.storage-header,
.storage-hero {
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(118, 132, 150, 0.2);
  box-shadow: 0 12px 30px rgba(34, 44, 64, 0.08);
  backdrop-filter: blur(10px);
}

.storage-header {
  position: sticky;
  top: 0;
  z-index: 24;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
}

.storage-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  width: 100%;
}

.storage-header-actions .status {
  flex: 1 1 220px;
  min-width: 0;
}

.storage-hero {
  padding: 18px;
}

.storage-hero-title {
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 700;
  line-height: 1.05;
  margin-top: 4px;
}

.storage-hero-text {
  margin: 12px 0 0;
  max-width: 780px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.storage-catalog {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  padding-bottom: 28px;
}

.storage-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(118, 132, 150, 0.18);
  box-shadow: 0 10px 24px rgba(34, 44, 64, 0.06);
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.storage-card:hover {
  transform: translateY(-1px);
}

.storage-card-running {
  border-color: var(--accent-dark);
  box-shadow: 0 12px 24px rgba(125, 72, 32, 0.18);
}

.storage-shot {
  position: relative;
  overflow: hidden;
  min-height: 176px;
  border: 1px solid rgba(42, 38, 32, 0.12);
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0) 42%),
    linear-gradient(135deg, var(--storage-shot-accent-soft) 0%, #fff7ec 55%, var(--storage-shot-accent) 100%);
}

.storage-shot::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(42, 38, 32, 0.06) 1px, transparent 1px) 0 0 / 18px 18px,
    linear-gradient(rgba(42, 38, 32, 0.06) 1px, transparent 1px) 0 0 / 18px 18px;
  pointer-events: none;
}

.storage-shot-window {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 16px;
  bottom: 16px;
  border: 1px solid rgba(42, 38, 32, 0.16);
  background: rgba(255, 250, 241, 0.88);
  box-shadow: 0 8px 18px rgba(36, 31, 26, 0.12);
}

.storage-shot-toolbar {
  height: 18px;
  background:
    linear-gradient(90deg, rgba(42, 38, 32, 0.08) 0 18px, transparent 18px calc(100% - 18px), rgba(42, 38, 32, 0.08) calc(100% - 18px)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(221, 206, 188, 0.92));
  border-bottom: 1px solid rgba(42, 38, 32, 0.12);
}

.storage-shot-body {
  position: absolute;
  inset: 19px 0 0;
  padding: 10px 12px;
  overflow: hidden;
}

.storage-shot-grid {
  position: absolute;
  inset: 10px 12px;
  background:
    linear-gradient(90deg, rgba(42, 38, 32, 0.05) 1px, transparent 1px) 0 0 / 14px 14px,
    linear-gradient(rgba(42, 38, 32, 0.05) 1px, transparent 1px) 0 0 / 14px 14px;
  opacity: 0.7;
}

.storage-shot-title {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  padding: 8px 12px;
  border: 1px solid rgba(42, 38, 32, 0.14);
  background: rgba(255, 250, 241, 0.9);
  font-family: var(--mono);
  font-size: 16px;
  letter-spacing: 0.5px;
}

.storage-card-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.storage-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.storage-app-name {
  font-size: 20px;
  font-weight: 700;
}

.storage-app-path {
  color: var(--muted);
}

.storage-badge {
  padding: 6px 10px;
  border: 1px solid rgba(42, 38, 32, 0.12);
  background: rgba(255, 255, 255, 0.54);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.storage-card-description {
  margin: 0;
  color: var(--ink);
  line-height: 1.45;
  min-height: 64px;
}

.storage-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.storage-card-state {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.storage-card-running .storage-card-state {
  color: var(--accent-dark);
}

.storage-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.storage-actions button {
  min-width: 96px;
  position: relative;
  z-index: 40;
}

.storage-hidden-ui {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

body.storage-page .workspace-desktop,
body.storage-page .workspace-desktop-canvas {
  pointer-events: none;
}

body.storage-page .workspace-desktop {
  background: transparent;
}

body.storage-page .workspace-desktop-canvas {
  display: none;
  z-index: 0;
}

body.storage-page .workspace-window,
body.storage-page .workspace-window-shell,
body.storage-page .workspace-window-canvas {
  pointer-events: auto;
}

body.storage-page .workspace-window {
  z-index: 24;
}

body.storage-page .workspace-window-chrome {
  pointer-events: none;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 8px 20px var(--shadow);
}

.title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.status {
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: #fef7ea;
}

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.file-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  cursor: pointer;
  font-family: var(--mono);
}

.file-picker input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}

.toggle input {
  accent-color: var(--accent);
}

.cpu-backend-control {
  cursor: default;
}

.cpu-backend-control select,
.launcher-select select {
  appearance: none;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  min-width: 88px;
  padding: 0;
  cursor: pointer;
  outline: none;
}

.cpu-backend-control select {
  color: var(--ink);
}

.launcher-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.launcher-select select {
  color: #f3f3f3;
}

.fs-root-status {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  padding: 8px 10px;
  border: 1px dashed var(--border);
  background: rgba(255, 250, 241, 0.85);
  min-width: 240px;
}

button {
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--panel);
  cursor: pointer;
  font-family: var(--mono);
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-family: var(--mono);
  text-decoration: none;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent-dark);
  color: #fffaf1;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  gap: 20px;
  align-items: start;
}

.screen-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 10px 24px var(--shadow);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  justify-self: stretch;
  min-width: 0;
}

.screen-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.screen-title {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.screen-action {
  padding: 6px 10px;
  font-size: 12px;
}

.workspace {
  position: relative;
  min-height: 68vh;
  height: min(78vh, 860px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border);
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0) 42%),
    linear-gradient(135deg, #bfcfbe 0%, #a4b798 42%, #8ea27f 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.workspace:fullscreen,
.workspace:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  border: none;
  box-shadow: none;
  overflow: hidden;
}

.workspace:fullscreen .workspace-empty,
.workspace:-webkit-full-screen .workspace-empty {
  inset: 20px;
}

.screen-panel:fullscreen,
.screen-panel:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  margin: 0;
  padding: 12px;
  border: none;
  box-shadow: none;
}

.screen-panel:fullscreen .workspace,
.screen-panel:-webkit-full-screen .workspace {
  min-height: 0;
  height: auto;
  flex: 1 1 auto;
}

.screen-panel:fullscreen .workspace-empty,
.screen-panel:-webkit-full-screen .workspace-empty {
  inset: 20px;
}

.workspace::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.08)) 0 0 / 100% 1px no-repeat,
    linear-gradient(90deg, rgba(42, 38, 32, 0.06) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(rgba(42, 38, 32, 0.06) 1px, transparent 1px) 0 0 / 28px 28px;
  pointer-events: none;
}

.workspace.workspace-drop-target {
  box-shadow:
    inset 0 0 0 2px rgba(201, 125, 36, 0.68),
    inset 0 0 0 10px rgba(255, 246, 231, 0.18);
}

.workspace.workspace-drop-target::before {
  background:
    linear-gradient(rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.08)) 0 0 / 100% 1px no-repeat,
    linear-gradient(rgba(201, 125, 36, 0.12), rgba(201, 125, 36, 0.12)),
    linear-gradient(90deg, rgba(42, 38, 32, 0.06) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(rgba(42, 38, 32, 0.06) 1px, transparent 1px) 0 0 / 28px 28px;
}

.workspace.workspace-drop-target .workspace-empty {
  border-color: rgba(201, 125, 36, 0.62);
  background: rgba(255, 246, 231, 0.4);
  color: rgba(78, 52, 28, 0.9);
}

.workspace-empty {
  position: absolute;
  inset: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: rgba(42, 38, 32, 0.7);
  font-family: var(--mono);
  font-size: 13px;
  text-align: center;
  border: 1px dashed rgba(255, 250, 241, 0.55);
  background: rgba(255, 250, 241, 0.22);
  backdrop-filter: blur(2px);
}

.workspace-empty[hidden] {
  display: none;
}

body.launcher-page .launcher-workspace {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  border: none;
  background: #000;
  box-shadow: none;
}

body.launcher-page .launcher-workspace::before {
  display: none;
}

.workspace-desktop {
  position: relative;
  min-width: 100%;
  min-height: 100%;
}

.workspace-desktop-canvas {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  width: auto;
  height: auto;
  z-index: 0;
  image-rendering: pixelated;
  touch-action: none;
  -webkit-touch-callout: none;
}

.workspace-window {
  position: absolute;
  left: 0;
  top: 0;
  overflow: hidden;
  background: transparent;
  box-shadow: 0 12px 26px rgba(36, 31, 26, 0.28);
}

.workspace-window-pending {
  display: none;
}

.workspace-window-minimized {
  display: none;
}

.workspace-window.active {
  box-shadow: 0 18px 34px rgba(36, 31, 26, 0.36);
}

.workspace-window-shaped,
.workspace-window-shaped.active,
.workspace-window-shaped.workspace-window-stopped,
.workspace-window-shaped.workspace-window-rolled-up {
  box-shadow: none;
}

.workspace-window-stopped {
  filter: saturate(0.8);
  box-shadow: 0 10px 22px rgba(72, 36, 36, 0.34);
}

.workspace-window-rolled-up {
  box-shadow: 0 10px 22px rgba(36, 31, 26, 0.24);
}

.workspace-window-shell {
  position: relative;
  display: block;
  overflow: hidden;
  line-height: 0;
  outline: none;
  background: #0f0f0f;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.workspace-window-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: auto;
  height: auto;
  image-rendering: pixelated;
}

.workspace-window-chrome {
  position: absolute;
  inset: 0;
  display: block;
  width: auto;
  height: auto;
  pointer-events: none;
  image-rendering: pixelated;
}

.screen-footer {
  font-size: 12px;
  color: var(--muted);
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  width: min(360px, 100%);
  justify-self: end;
  position: sticky;
  top: 24px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 6px 16px var(--shadow);
  padding: 12px;
}

.card-title {
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 8px;
}

.mono {
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  margin: 0;
  max-height: 260px;
  overflow: auto;
}

@media (max-width: 900px) {
  .main {
    grid-template-columns: 1fr;
  }

  .storage-overlay {
    padding: 12px;
  }

  .storage-header-actions {
    align-items: stretch;
  }

  .storage-header-actions .status,
  .storage-header-actions .toggle,
  .storage-header-actions .button-link,
  .storage-header-actions button {
    width: auto;
  }

  .storage-card-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .storage-actions {
    width: 100%;
  }

  .storage-actions button {
    flex: 1 1 0;
  }
}

@media (max-width: 1100px) {
  .storage-catalog {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .storage-catalog {
    grid-template-columns: 1fr;
  }

  .storage-header-actions .status,
  .storage-header-actions .toggle,
  .storage-header-actions .button-link,
  .storage-header-actions button {
    width: 100%;
  }
}
