:root {
  --ink: #0c0c0c;
  --paper: #f6f5f1;
  --hit: #c8ff2e;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --grotesk: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #1a1918;
  font-family: var(--grotesk);
  -webkit-font-smoothing: antialiased;
}

#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  /* Before the camera, the wallpaper is soft fog. */
  /* Fallback if the painted wallpaper can't draw: the same dreamy haze, still. */
  background:
    radial-gradient(45% 55% at 52% 45%, #f6ffd8 0%, #e2f0b8 35%, transparent 70%),
    linear-gradient(180deg, #d6d1eb 0%, #e6f0d2 45%, #8c85b8 78%, #241f3d 100%);
}

/* Before the camera: a soft, dreamy wallpaper with liquid light and star glints. */
#paper {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transition: opacity 1.2s ease;
}
#paper.away { opacity: 0; }

/* You are the wallpaper: the camera fills the screen, mirrored like a mirror. */
#cam {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  opacity: 0;
  transition: opacity 1.2s ease;
}
#cam.live { opacity: 1; }

#desk, #marks {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#marks { pointer-events: none; z-index: 5000; }
#desk { touch-action: none; }

/* ---------- desktop icons */

.icon {
  position: absolute;
  left: 0;
  top: 0;
  width: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  will-change: transform;
}
.icon canvas {
  width: 64px;
  height: 64px;
  pointer-events: none;
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.28));
}
.icon .name {
  max-width: 88px;
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 11px;
  line-height: 1.25;
  font-weight: 500;
  text-align: center;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
  overflow-wrap: anywhere;
  pointer-events: none;
}
.icon.on .name {
  background: var(--hit);
  color: var(--ink);
  text-shadow: none;
}
.icon.on canvas {
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.28)) brightness(0.82);
}

/* ---------- menu bar */

#bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 28px;
  z-index: 6000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 14px;
  background: rgba(246, 245, 241, 0.62);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  font-size: 13px;
  color: var(--ink);
}
#bar .left, #bar .right {
  display: flex;
  align-items: center;
  gap: 18px;
  white-space: nowrap;
}
#bar b { font-weight: 700; }
.mark {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: inset -3px 0 0 var(--hit);
}
#readout {
  font: 10px/1 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.6;
}
#clock { font-variant-numeric: tabular-nums; }

.menu { position: relative; }
#viewBtn {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 2px 8px;
  margin: 0 -8px;
  border-radius: 4px;
}
#viewBtn:hover, #viewBtn[aria-expanded="true"] { background: rgba(0, 0, 0, 0.1); }
#viewMenu {
  position: absolute;
  top: 24px;
  left: -8px;
  min-width: 150px;
  padding: 5px;
  border-radius: 8px;
  background: rgba(246, 245, 241, 0.86);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.25), 0 8px 24px rgba(0, 0, 0, 0.18);
}
#viewMenu button {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 4px 10px;
  border-radius: 4px;
}
#viewMenu button:hover, #viewMenu button:focus-visible { background: var(--hit); outline: none; }

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

/* ---------- dock */

#dock {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px;
  border-radius: 18px;
  background: rgba(246, 245, 241, 0.34);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.5), 0 0 0 0.5px rgba(0, 0, 0, 0.2);
}
.sep { width: 1px; align-self: stretch; margin: 4px 2px; background: rgba(0, 0, 0, 0.22); }
.app {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  overflow: hidden;
  transition: transform 0.25s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.app i { display: block; font-style: normal; }

.files { background: linear-gradient(#eef4fb, #d7e4f2); }
.files i { width: 30px; height: 22px; margin-top: 4px; border-radius: 3px; background: #5aa9ef; box-shadow: -6px -5px 0 -2px #3f8fde; }
.mail { background: linear-gradient(#5fb4ff, #1f7fe8); }
.mail i { width: 28px; height: 19px; border-radius: 3px; background: #fff; clip-path: polygon(0 0, 50% 55%, 100% 0, 100% 100%, 0 100%); }
.notes { background: linear-gradient(#fff 0 26%, #fff7c7 26%); }
.notes i { width: 30px; height: 18px; margin-top: 10px; background: repeating-linear-gradient(#fff7c7 0 4px, #d8cf9a 4px 5px); }
.music { background: linear-gradient(#ff6b7d, #f0233d); }
.music i { width: 10px; height: 10px; border-radius: 50%; background: #fff; box-shadow: 10px -4px 0 #fff; transform: translate(-4px, 6px); }
.music::after { content: ""; position: absolute; left: 20px; top: 11px; width: 13px; height: 20px; border: 2.5px solid #fff; border-bottom: 0; border-left-width: 2.5px; transform: skewY(-12deg); }
.photos { background: #fff; display: block; }
.photos i { position: absolute; left: 50%; top: 50%; width: 12px; height: 20px; margin: -20px 0 0 -6px; border-radius: 6px; transform-origin: 6px 20px; mix-blend-mode: multiply; }
.photos i:nth-child(1) { background: #ff9f1c; }
.photos i:nth-child(2) { background: #ff3d6e; transform: rotate(90deg); }
.photos i:nth-child(3) { background: #3aa7ff; transform: rotate(180deg); }
.photos i:nth-child(4) { background: #46d36b; transform: rotate(270deg); }
.camera { background: linear-gradient(#3a3a3a, #121212); }
.camera i { width: 20px; height: 20px; border-radius: 50%; background: radial-gradient(circle at 40% 40%, #6b8cff 0 18%, #0b0b0b 22% 52%, #555 56% 64%, #1b1b1b 68%); }
.camera::after { content: ""; position: absolute; top: 7px; right: 8px; width: 4px; height: 4px; border-radius: 50%; background: #333; }
.camera.on::after { background: #46d36b; }
.term { background: #111; }
.term i { font: 700 15px/1 var(--mono); color: #f6f5f1; transform: translate(-5px, -4px); }
.trash { background: rgba(255, 255, 255, 0.18); }
.trash i { width: 24px; height: 30px; border-radius: 2px 2px 5px 5px; background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.9) 0 2px, rgba(255, 255, 255, 0.45) 2px 6px); box-shadow: 0 -4px 0 -2px rgba(255, 255, 255, 0.9); }
.trash.full i { background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.9) 0 2px, rgba(255, 255, 255, 0.45) 2px 6px), radial-gradient(circle at 50% 10%, #fff 0 40%, transparent 42%); }
.trash.full::before { content: ""; position: absolute; top: 4px; left: 13px; width: 20px; height: 10px; border-radius: 40% 60% 30% 50%; background: #fff; transform: rotate(-8deg); }
.trash.near { transform: scale(1.16) translateY(-4px); }
.camera.on { transform: none; }
.app:hover { transform: translateY(-3px); }
.dot {
  position: absolute;
  bottom: -5px;
  left: 50%;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
}

/* ---------- hint */

#hint {
  position: absolute;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6000;
  margin: 0;
  font: 10px/1.4 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  white-space: nowrap;
  transition: opacity 0.8s ease;
}
#hint.gone { opacity: 0; }

/* ---------- the camera ask */

#ask {
  position: absolute;
  z-index: 7000;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  width: min(300px, calc(100vw - 32px));
  padding: 14px 18px 16px;
  border-radius: 12px;
  background: rgba(246, 245, 241, 0.88);
  backdrop-filter: blur(30px) saturate(1.4);
  -webkit-backdrop-filter: blur(30px) saturate(1.4);
  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.3), 0 18px 50px rgba(0, 0, 0, 0.3);
  color: var(--ink);
  text-align: center;
}
#ask[hidden] { display: none; }
.lights { display: flex; gap: 6px; margin-bottom: 14px; }
.lights i { width: 10px; height: 10px; border-radius: 50%; background: rgba(0, 0, 0, 0.16); }
#ask h1 { margin: 0 0 6px; font-size: 13px; line-height: 1.3; font-weight: 700; }
#ask p { margin: 0; font-size: 11px; line-height: 1.4; color: rgba(12, 12, 12, 0.7); }
#ask .row { display: flex; gap: 8px; margin-top: 16px; }
#ask .row button {
  flex: 1;
  font: 500 13px/1 var(--grotesk);
  padding: 7px 0;
  border-radius: 6px;
  border: 0;
  background: rgba(0, 0, 0, 0.08);
  color: var(--ink);
}
#ask #allow { background: var(--ink); color: #fff; }
#ask #allow:disabled { opacity: 0.5; }
#status { margin-top: 10px !important; font: 10px/1.4 var(--mono) !important; text-transform: uppercase; letter-spacing: 0.04em; }
#status:empty { display: none; }

@media (max-width: 720px) {
  #bar .opt, #readout { display: none; }
  #bar .left { gap: 14px; }
  .app { width: 34px; height: 34px; border-radius: 8px; }
  .app i { transform: scale(0.75); }
  #dock { gap: 5px; padding: 5px; border-radius: 13px; }
  .music::after { left: 14px; top: 7px; width: 10px; height: 15px; border-width: 2px; }
  .music i { transform: scale(0.75) translate(-6px, 6px); }
  #hint { bottom: 64px; white-space: normal; width: calc(100vw - 32px); text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .app, #cam, #hint { transition: none; }
}

/* A folder you're hovering a file over: its name lights up like a drop target. */
.icon.drop .name {
  background: var(--hit);
  color: var(--ink);
  text-shadow: none;
}
