:root {
  --ink: #fff;
  --muted: rgb(255 255 255 / .68);
  --accent: #5ac8fa;
  --danger: #ff6b60;
  --glass: rgb(38 44 70 / .42);
  --glass-thick: rgb(30 35 58 / .58);
  --glass-control: rgb(255 255 255 / .14);
  --glass-hover: rgb(255 255 255 / .26);
  --blur: blur(28px) saturate(190%);
  /* Bright top rim and soft inner glow give the sheet its liquid edge. */
  --rim: inset 0 1px 0 rgb(255 255 255 / .55), inset 0 0 0 1px rgb(255 255 255 / .16), inset 0 -1px 1px rgb(255 255 255 / .12), inset 0 14px 28px -18px rgb(255 255 255 / .5);
  --lift: 0 22px 60px rgb(5 8 30 / .45), 0 2px 8px rgb(5 8 30 / .25);
  --wallpaper:
    radial-gradient(60% 70% at 15% 15%, #ff7ab8 0, transparent 70%),
    radial-gradient(55% 65% at 85% 10%, #ffb25c 0, transparent 70%),
    radial-gradient(70% 70% at 80% 85%, #2fd6d0 0, transparent 70%),
    radial-gradient(70% 80% at 15% 90%, #3f5bff 0, transparent 72%),
    #5b3fd6;
  font: 13px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; background: #5b3fd6; }
button, input { font: inherit; color: inherit; }

/* Shared glass surface */
.login, .win, .menu, .toast {
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--rim), var(--lift);
}

/* Login */
.login-page { display: grid; place-items: center; background: var(--wallpaper); }
.login { width: min(340px, calc(100vw - 32px)); padding: 28px; display: grid; gap: 10px; border-radius: 32px; }
.login h1 { margin: 0 0 10px; font-size: 26px; font-weight: 700; letter-spacing: -.02em; text-align: center; }
.login label { color: var(--muted); padding-left: 14px; }
.login input { padding: 12px 16px; background: var(--glass-control); border: 0; border-radius: 999px; box-shadow: inset 0 1px 2px rgb(0 0 0 / .25), inset 0 0 0 1px rgb(255 255 255 / .16); outline: 0; }
.login input:focus { box-shadow: inset 0 0 0 2px var(--accent); }
.login-error { min-height: 18px; margin: 0; padding-left: 14px; color: #ffd0cb; }
.login button { padding: 12px; border: 0; border-radius: 999px; background: rgb(255 255 255 / .9); color: #1a1d33; font-weight: 600; cursor: pointer; box-shadow: inset 0 1px 0 #fff, 0 6px 18px rgb(5 8 30 / .3); transition: transform .18s cubic-bezier(.3, 1.6, .5, 1); }
.login button:hover { transform: scale(1.02); }
.login button:active { transform: scale(.97); }

/* Desktop */
#desktop { position: fixed; inset: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; background: var(--wallpaper); }
.icon { position: absolute; width: 84px; height: 104px; padding: 5px 4px; display: flex; flex-direction: column; align-items: center; gap: 5px; border-radius: 20px; touch-action: none; transition: background .15s; }
.icon:hover { background: rgb(255 255 255 / .1); }
.icon.selected { background: rgb(255 255 255 / .22); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .55), inset 0 1px 0 rgb(255 255 255 / .6); }
.icon.drop-target { background: rgb(255 255 255 / .38); box-shadow: inset 0 0 0 2px #fff; }
.icon.dragging { opacity: .88; z-index: 100000; }
.glyph { flex: none; pointer-events: none; }
.icon .glyph { width: 56px; height: 56px; padding: 9px; border-radius: 16px; background: rgb(255 255 255 / .2); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); box-shadow: var(--rim), 0 8px 20px rgb(5 8 30 / .3); transition: transform .2s cubic-bezier(.3, 1.6, .5, 1); }
.icon:hover .glyph { transform: scale(1.05); }
.label { max-width: 100%; font-weight: 500; line-height: 16px; text-align: center; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; text-shadow: 0 1px 4px rgb(0 0 0 / .65); pointer-events: none; }
.rename { width: 100%; padding: 2px 4px; text-align: center; color: #111; background: rgb(255 255 255 / .92); border: 0; border-radius: 8px; outline: 2px solid var(--accent); user-select: text; -webkit-user-select: text; }
.rubber { position: absolute; z-index: 99999; pointer-events: none; border-radius: 12px; background: rgb(255 255 255 / .14); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .75), inset 0 1px 0 rgb(255 255 255 / .8), 0 6px 22px rgb(5 8 30 / .22); }

/* Window */
.win { position: absolute; display: flex; flex-direction: column; min-width: 0; border-radius: 28px; overflow: hidden; }
.win.minimized { display: none; }
.win.maximized { inset: 0 0 76px !important; width: auto !important; height: auto !important; border-radius: 0; }
.titlebar { height: 52px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 12px 0 20px; touch-action: none; }
.titlebar .title { flex: 1; font-size: 15px; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.titlebar button { width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: var(--glass-control); box-shadow: inset 0 1px 0 rgb(255 255 255 / .35), inset 0 0 0 1px rgb(255 255 255 / .1); cursor: pointer; font-size: 13px; transition: transform .18s cubic-bezier(.3, 1.6, .5, 1), background .15s; }
.titlebar button:hover { background: var(--glass-hover); transform: scale(1.08); }
.titlebar button:active { transform: scale(.92); }
.titlebar button.close:hover { background: var(--danger); }
.toolbar { display: flex; gap: 8px; padding: 0 14px 10px; }
.toolbar button { padding: 7px 14px; background: var(--glass-control); border: 0; border-radius: 999px; box-shadow: inset 0 1px 0 rgb(255 255 255 / .35), inset 0 0 0 1px rgb(255 255 255 / .1); font-weight: 500; cursor: pointer; transition: transform .18s cubic-bezier(.3, 1.6, .5, 1), background .15s; }
.toolbar button:hover:not(:disabled) { background: var(--glass-hover); }
.toolbar button:active:not(:disabled) { transform: scale(.96); }
.toolbar button:disabled { opacity: .45; cursor: default; }
.list { flex: 1; overflow: auto; margin: 0 8px 8px; padding: 6px; border-radius: 20px; background: rgb(10 12 30 / .16); scrollbar-width: thin; scrollbar-color: rgb(255 255 255 / .3) transparent; }
.row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 13px; }
.row:hover { background: rgb(255 255 255 / .1); }
.row.selected { background: rgb(255 255 255 / .24); box-shadow: inset 0 1px 0 rgb(255 255 255 / .35); }
.row .glyph { width: 22px; height: 22px; }
.row .name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.crumbs { flex: 1; min-width: 0; align-self: center; padding: 0 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); }
.row .name { flex: 1; min-width: 0; }
.row .size { flex: none; color: var(--muted); }
.row.cut { opacity: .5; }
.row .rename { flex: 1; text-align: left; }
.toast.neutral { color: var(--ink); }
.empty { padding: 40px 12px; text-align: center; color: var(--muted); }
.grip { position: absolute; z-index: 2; touch-action: none; }
.grip.n, .grip.s { left: 22px; right: 22px; height: 6px; cursor: ns-resize; }
.grip.e, .grip.w { top: 22px; bottom: 22px; width: 6px; cursor: ew-resize; }
.grip.n { top: 0; } .grip.s { bottom: 0; } .grip.e { right: 0; } .grip.w { left: 0; }
.grip.ne, .grip.nw, .grip.se, .grip.sw { width: 20px; height: 20px; }
.grip.ne { top: 0; right: 0; cursor: nesw-resize; } .grip.sw { bottom: 0; left: 0; cursor: nesw-resize; }
.grip.nw { top: 0; left: 0; cursor: nwse-resize; } .grip.se { bottom: 0; right: 0; cursor: nwse-resize; }
.win.maximized .grip { display: none; }

.frame { flex: 1; min-height: 0; width: 100%; border: 0; background: #000; }
.win-dragging .frame { pointer-events: none; }

/* Dock */
.dock { position: fixed; z-index: 150000; left: 50%; bottom: 10px; transform: translateX(-50%); max-width: calc(100vw - 16px); height: 58px; padding: 7px; display: flex; align-items: center; gap: 8px; border-radius: 29px; background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); box-shadow: var(--rim), var(--lift); user-select: none; -webkit-user-select: none; }
.dock button { border: 0; cursor: pointer; transition: transform .18s cubic-bezier(.3, 1.6, .5, 1), background .15s; }
.dock button:active { transform: scale(.94); }
.start { flex: none; width: 44px; height: 44px; padding: 10px; border-radius: 50%; background: var(--glass-control); box-shadow: inset 0 1px 0 rgb(255 255 255 / .35); }
.start:hover { background: var(--glass-hover); }
.start .glyph { display: block; width: 24px; height: 24px; }
.running { display: flex; gap: 6px; min-width: 0; overflow: hidden; }
.running:empty { display: none; }
.task { flex: none; width: 44px; height: 44px; padding: 8px; display: grid; place-items: center; border-radius: 50%; background: rgb(255 255 255 / .08); }
.task:hover { background: var(--glass-hover); }
.task.active { background: rgb(255 255 255 / .28); box-shadow: inset 0 1px 0 rgb(255 255 255 / .5); }
.task.minimized { opacity: .65; }
.task .glyph { width: 28px; height: 28px; }

/* Start menu */
.start-menu { width: min(360px, calc(100vw - 16px)); padding: 10px; border-radius: 26px; transform-origin: bottom left; }
.start-menu .search { width: 100%; height: 42px; margin-bottom: 8px; padding: 0 16px; background: rgb(10 12 30 / .22); border: 0; border-radius: 21px; box-shadow: inset 0 0 0 1px rgb(255 255 255 / .14); outline: 0; }
.start-menu .search::placeholder { color: var(--muted); }
.start-menu .search:focus { box-shadow: inset 0 0 0 2px var(--accent); }
.results { max-height: 50vh; overflow: auto; scrollbar-width: thin; }
.menu button.hit { display: flex; align-items: center; gap: 10px; }
.hit .glyph { width: 28px; height: 28px; }
.hit span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.no-hits { padding: 18px; text-align: center; color: var(--muted); }

/* Text editor */
.editor { flex: 1; min-height: 0; margin: 0 8px 8px; padding: 12px 14px; resize: none; color: var(--ink); background: rgb(10 12 30 / .22); border: 0; border-radius: 20px; outline: 0; font: 14px/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace; user-select: text; -webkit-user-select: text; }
.editor:disabled { opacity: .6; }

.viewer { flex: 1; min-height: 0; display: grid; place-items: center; margin: 0 8px 8px; border-radius: 20px; overflow: hidden; background: rgb(10 12 30 / .22); }
.viewer img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer img[hidden], .viewer .empty[hidden] { display: none; }

/* Dock preview */
.preview { position: fixed; z-index: 170000; padding: 8px 10px 10px; border-radius: 18px; background: var(--glass-thick); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); box-shadow: var(--rim), var(--lift); cursor: pointer; animation: pop .16s ease-out; transform-origin: bottom center; }
.preview:hover { background: rgb(60 66 100 / .62); }
.preview-title { max-width: 240px; padding: 0 2px 6px; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.preview-body { position: relative; overflow: hidden; border-radius: 10px; background: #0d1020; pointer-events: none; }
.preview-body canvas { display: block; width: 100%; height: 100%; }
.restarting { position: fixed; inset: 0; z-index: 300000; display: grid; place-items: center; font-size: 20px; font-weight: 600; background: rgb(10 12 30 / .5); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }

/* Menu and notices */
.menu { position: fixed; z-index: 200000; min-width: 200px; padding: 6px; border-radius: 22px; background: var(--glass-thick); animation: pop .2s cubic-bezier(.3, 1.4, .5, 1); transform-origin: top left; }
.menu button { display: block; width: 100%; padding: 8px 12px; text-align: left; background: none; border: 0; border-radius: 15px; cursor: pointer; }
.menu button:hover:not(:disabled) { background: var(--glass-hover); }
.menu button:disabled { opacity: .45; cursor: default; }
.menu button.danger { color: #ff9f97; }
.menu hr { margin: 5px 12px; border: 0; border-top: 1px solid rgb(255 255 255 / .2); }
.toast { position: fixed; z-index: 200001; left: 50%; bottom: 24px; transform: translateX(-50%); padding: 11px 20px; border-radius: 999px; background: var(--glass-thick); font-weight: 600; }
@keyframes pop { from { opacity: 0; transform: scale(.88); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
