/* Easy Make Oven - Desktop
   Same look as the G-code Simulator, PCB Designer and SVG Editor. */
:root {
  --bg: #0f1319; --panel: #171c24; --panel2: #1e2530; --line: #2a3340; --text: #dfe6ee; --muted: #8b98a8;
  --accent: #40c4ff; --accent2: #ffab40; --danger: #ff5252; --ok: #69f0ae;
  --on-accent: #001;
  --glass: rgba(23, 28, 36, .86);
  --shadow: 0 18px 50px rgba(0, 0, 0, .55);
  --taskbar-h: 48px;
  --radius: 10px;
}
body.light {
  --bg: #e9edf2; --panel: #ffffff; --panel2: #f2f5f8; --line: #d5dce4; --text: #1d2733; --muted: #66748a;
  --accent: #0277bd; --accent2: #e65100; --danger: #c62828; --ok: #2e7d32;
  --on-accent: #fff;
  --glass: rgba(255, 255, 255, .88);
  --shadow: 0 18px 50px rgba(20, 30, 45, .28);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font: 13px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------- desktop ---------------- */
.desktop { position: fixed; inset: 0 0 var(--taskbar-h) 0; overflow: hidden; background-size: cover !important; }
.desktop::before { /* faint maker grid over the wallpaper */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,.07) 1px, transparent 1px); background-size: 24px 24px; }
.icon-layer { position: absolute; inset: 0; z-index: 1; }

.dicon { position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px;
  padding: 8px 4px 4px; border: 1px solid transparent; border-radius: 10px; background: none; color: #fff;
  text-align: center; touch-action: none; user-select: none; transition: background .12s, border-color .12s, left .18s, top .18s; }
.dicon:hover { background: rgba(255,255,255,.10); border-color: rgba(255,255,255,.12); }
.dicon:focus-visible, .dicon.sel { background: rgba(64,196,255,.18); border-color: rgba(64,196,255,.55); outline: 0; }
.dicon.dragging { transition: none; z-index: 5; opacity: .9; background: rgba(64,196,255,.22); cursor: grabbing; }
.dicon .ico { display: flex; align-items: center; justify-content: center; filter: drop-shadow(0 3px 5px rgba(0,0,0,.45)); pointer-events: none; }
.dicon .ico img { width: 100%; height: 100%; object-fit: contain; }
.dicon .lbl { font-size: 12.5px; font-weight: 500; line-height: 1.2; text-shadow: 0 1px 3px #000, 0 0 2px #000; width: 100%; pointer-events: none;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.dicon .lock { position: absolute; top: 6px; right: 10px; font-size: 11px; color: var(--accent2); text-shadow: 0 1px 2px #000; pointer-events: none; }
.drop-target { position: absolute; border: 2px dashed rgba(64,196,255,.7); border-radius: 10px; pointer-events: none; z-index: 0; }

/* generic icon rendering */
.ico i.bi, .ico .emoji, .ico iconify-icon { line-height: 1; }
.ico-folder { color: var(--accent2); }

/* ---------------- windows ---------------- */
.window-layer { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.win { position: absolute; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; pointer-events: auto; min-width: 280px; min-height: 180px;
  transition: opacity .16s ease, transform .16s ease; }
.win.opening { opacity: 0; transform: scale(.97) translateY(8px); }
.win.closing { opacity: 0; transform: scale(.97); }
.win.max { left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important; border-radius: 0; border-width: 0; }
.win.min { display: none; }
.win-bar { display: flex; align-items: center; gap: 8px; height: 38px; flex-shrink: 0; padding: 0 4px 0 10px; background: var(--panel2);
  border-bottom: 1px solid var(--line); cursor: default; user-select: none; touch-action: none; }
.win.active .win-bar { box-shadow: inset 0 2px 0 var(--accent); }
.win-ico { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.win-ico img { width: 18px; height: 18px; object-fit: contain; }
.win-title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win:not(.active) .win-title { color: var(--muted); }
.win-btns { display: flex; gap: 2px; }
.win-btns button { width: 34px; height: 30px; border: 0; border-radius: 6px; background: none; color: var(--muted); font-size: 14px;
  display: flex; align-items: center; justify-content: center; }
.win-btns button:hover { background: var(--line); color: var(--text); }
.win-btns button.close:hover { background: var(--danger); color: #fff; }
.win-body { position: relative; flex: 1; min-height: 0; background: var(--bg); }
.win-body iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; background: transparent; }
.win-shield { position: absolute; inset: 0; display: none; z-index: 2; }
body.wm-busy .win-shield { display: block; } /* stops iframes stealing the mouse while dragging */
body.wm-busy { user-select: none; }
.win-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 1; background: var(--bg); color: var(--muted); gap: 10px; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.rz { position: absolute; z-index: 3; touch-action: none; }
.rz.n, .rz.s { left: 8px; right: 8px; height: 6px; cursor: ns-resize; }
.rz.n { top: -3px; } .rz.s { bottom: -3px; }
.rz.e, .rz.w { top: 8px; bottom: 8px; width: 6px; cursor: ew-resize; }
.rz.e { right: -3px; } .rz.w { left: -3px; }
.rz.ne, .rz.nw, .rz.se, .rz.sw { width: 14px; height: 14px; }
.rz.ne { top: -3px; right: -3px; cursor: nesw-resize; } .rz.sw { bottom: -3px; left: -3px; cursor: nesw-resize; }
.rz.nw { top: -3px; left: -3px; cursor: nwse-resize; } .rz.se { bottom: -3px; right: -3px; cursor: nwse-resize; }
.win.max .rz { display: none; }
.snap-preview { position: absolute; z-index: 1; border-radius: 10px; background: rgba(64,196,255,.16); border: 2px solid rgba(64,196,255,.6);
  transition: all .12s ease; pointer-events: none; }

/* ---------------- taskbar ---------------- */
.taskbar { position: fixed; left: 0; right: 0; bottom: 0; height: var(--taskbar-h); z-index: 9000; display: flex; align-items: center; gap: 4px;
  padding: 0 0 0 6px; background: var(--glass); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.start-btn { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px 0 6px; border: 1px solid transparent; border-radius: 8px;
  background: none; font-weight: 700; font-size: 14px; white-space: nowrap; }
.start-btn img { width: 28px; height: 28px; object-fit: contain; }
.start-btn:hover, .start-btn[aria-expanded=true] { background: var(--panel2); border-color: var(--line); }
.task-apps { display: flex; align-items: center; gap: 3px; min-width: 0; flex: 1; overflow-x: auto; scrollbar-width: none; padding: 0 4px; }
.task-apps::-webkit-scrollbar { display: none; }
.task-btn { position: relative; display: flex; align-items: center; gap: 7px; height: 38px; max-width: 190px; padding: 0 10px; border: 1px solid transparent;
  border-radius: 8px; background: none; white-space: nowrap; flex-shrink: 0; }
.task-btn:hover { background: var(--panel2); border-color: var(--line); }
.task-btn .ico { width: 20px; height: 20px; font-size: 17px; display: flex; align-items: center; justify-content: center; }
.task-btn .ico img { width: 20px; height: 20px; object-fit: contain; }
.task-btn .t { overflow: hidden; text-overflow: ellipsis; }
.task-btn.pinned:not(.running) .t { display: none; }
.task-btn.pinned:not(.running) { padding: 0 9px; }
.task-btn.running::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 6px; height: 3px; margin-left: -3px; border-radius: 2px; background: var(--muted); }
.task-btn.active { background: var(--panel2); border-color: var(--line); }
.task-btn.active::after { width: 16px; margin-left: -8px; background: var(--accent); }
.task-btn.min { opacity: .72; }
.tb-right { display: flex; align-items: center; gap: 2px; margin-left: auto; height: 100%; }
.tb-btn { height: 38px; min-width: 38px; border: 1px solid transparent; border-radius: 8px; background: none; font-size: 16px; display: flex; align-items: center; justify-content: center; gap: 4px; padding: 0 8px; }
.tb-btn:hover { background: var(--panel2); border-color: var(--line); }
.win-count span { font-size: 12px; font-weight: 700; }
.clock { display: flex; flex-direction: column; align-items: flex-end; justify-content: center; height: 40px; padding: 0 10px; border: 1px solid transparent; border-radius: 8px;
  background: none; line-height: 1.25; text-align: right; }
.clock:hover { background: var(--panel2); border-color: var(--line); }
.clock .who { font-size: 11.5px; font-weight: 600; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clock .time { font-size: 11.5px; color: var(--muted); }
.show-desktop { width: 10px; height: 100%; border: 0; border-left: 1px solid var(--line); background: none; padding: 0; }
.show-desktop:hover { background: var(--panel2); }

/* ---------------- popups (start menu, context menu, calendar) ---------------- */
.start-menu, .ctx-menu, .calendar-pop { position: fixed; z-index: 9500; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.start-menu { left: 8px; bottom: calc(var(--taskbar-h) + 8px); width: 400px; max-width: calc(100vw - 16px); max-height: min(640px, calc(100vh - var(--taskbar-h) - 20px));
  display: flex; flex-direction: column; overflow: hidden; animation: pop .14s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }
.sm-search { padding: 12px 12px 8px; }
.sm-search .box { display: flex; align-items: center; gap: 8px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; }
.sm-search .box:focus-within { border-color: var(--accent); }
.sm-search input { flex: 1; border: 0; background: none; outline: 0; padding: 9px 0; min-width: 0; }
.sm-search kbd { font: 11px inherit; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }
.sm-body { flex: 1; overflow: auto; padding: 0 8px 8px; min-height: 120px; }
.sm-h { display: flex; align-items: center; justify-content: space-between; margin: 10px 6px 4px; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.sm-h button { border: 0; background: none; color: var(--accent); font-size: 11.5px; text-transform: none; letter-spacing: 0; font-weight: 600; padding: 0; }
.sm-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none; text-align: left; }
.sm-item:hover, .sm-item.kb { background: var(--panel2); }
.sm-item .ico { width: 26px; height: 26px; font-size: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sm-item .ico img { width: 26px; height: 26px; object-fit: contain; }
.sm-item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sm-item .meta { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.sm-item .x { border: 0; background: none; color: var(--muted); border-radius: 6px; width: 26px; height: 26px; }
.sm-item .x:hover { background: var(--danger); color: #fff; }
.sm-item.back { color: var(--accent); font-weight: 600; }
.sm-item .lockic { color: var(--accent2); font-size: 12px; }
.sm-recent { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.sm-recent .sm-item { flex-direction: column; gap: 4px; padding: 10px 4px; text-align: center; }
.sm-recent .t { white-space: normal; font-size: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; width: 100%; }
.sm-empty { color: var(--muted); padding: 18px 10px; text-align: center; }
.sm-foot { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line); background: var(--panel2); }
.sm-user { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; font-weight: 600; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.sm-user .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sm-user .n small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; padding: 6px 11px; white-space: nowrap; color: var(--text); text-decoration: none; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.icon { width: 32px; height: 32px; padding: 0; }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }

.ctx-menu { min-width: 220px; padding: 5px; border-radius: 9px; animation: pop .1s ease; }
.ctx-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border: 0; border-radius: 6px; background: none; text-align: left; white-space: nowrap; }
.ctx-menu button:hover:not(:disabled) { background: var(--panel2); }
.ctx-menu button:disabled { opacity: .45; cursor: default; }
.ctx-menu button i { width: 16px; text-align: center; color: var(--muted); }
.ctx-menu button .k { margin-left: auto; color: var(--muted); font-size: 11px; padding-left: 16px; }
.ctx-menu button.on i { color: var(--accent); }
.ctx-menu button.danger { color: var(--danger); }
.ctx-menu button.danger i { color: var(--danger); }
.ctx-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }
.ctx-menu .ctx-h { padding: 6px 10px 3px; font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }

.calendar-pop { right: 8px; bottom: calc(var(--taskbar-h) + 8px); width: 300px; padding: 14px; animation: pop .14s ease; }
.cal-now { font-size: 26px; font-weight: 300; }
.cal-date { color: var(--accent); margin-bottom: 10px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 0; font-weight: 600; }
.cal-head button { border: 0; background: none; width: 30px; height: 28px; border-radius: 6px; }
.cal-head button:hover { background: var(--panel2); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal-grid div { padding: 6px 0; border-radius: 6px; font-size: 12px; }
.cal-grid .dow { color: var(--muted); font-size: 11px; }
.cal-grid .other { color: var(--muted); opacity: .45; }
.cal-grid .today { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.cal-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); }
.switch { display: flex; align-items: center; gap: 6px; cursor: pointer; }

/* ---------------- dialogs + toasts ---------------- */
.dialog-back { position: fixed; inset: 0; z-index: 9800; background: rgba(0,0,0,.5); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); width: min(380px, 100%); padding: 24px; text-align: center; animation: pop .15s ease; }
.dialog .big { font-size: 40px; color: var(--accent); line-height: 1; }
.dialog h2 { font-size: 18px; margin: 12px 0 6px; }
.dialog p { color: var(--muted); margin: 0 0 18px; }
.dialog .acts { display: grid; gap: 8px; }
.dialog .acts .btn { padding: 9px 12px; }
.toasts { position: fixed; right: 12px; bottom: calc(var(--taskbar-h) + 12px); z-index: 9900; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 9px; box-shadow: var(--shadow); padding: 10px 12px; max-width: min(360px, calc(100vw - 24px)); animation: pop .18s ease; }
.toast.err { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }
.toast i.lead { color: var(--accent); font-size: 18px; }
.toast.err i.lead { color: var(--danger); }
.toast.ok i.lead { color: var(--ok); }
.toast .body { flex: 1; }
.toast .body b { display: block; margin-bottom: 2px; }
.toast .acts { display: flex; gap: 6px; margin-top: 8px; }
.toast .x { border: 0; background: none; color: var(--muted); padding: 0 2px; }

/* ---------------- phones / small tablets ---------------- */
@media (max-width: 760px) {
  :root { --taskbar-h: 54px; }
  .start-label, .hide-sm, .clock .who { display: none; }
  .task-btn .t { display: none; }
  .task-btn { padding: 0 9px; }
  .win, .win.max { left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important; border-radius: 0; border-width: 0; }
  .rz, .win-btns [data-act=max] { display: none; }
  .start-menu { left: 6px; right: 6px; width: auto; bottom: calc(var(--taskbar-h) + 6px); max-height: calc(100vh - var(--taskbar-h) - 14px); }
  .calendar-pop { left: 6px; right: 6px; width: auto; }
  .sm-item { padding: 11px 10px; }
  .show-desktop { width: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
/* keep notifications clear of the open calendar */
.calendar-pop:not([hidden]) ~ .toasts { right: 320px; }
@media (max-width: 760px) { .calendar-pop:not([hidden]) ~ .toasts { right: 12px; bottom: 420px; } }
