/* ============ WebOS shell styles ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --taskbar-h: 48px;
  --accent: #4f8cff;
  --glass: rgba(20, 24, 40, 0.55);
  --glass-strong: rgba(18, 22, 38, 0.82);
  --stroke: rgba(255, 255, 255, 0.14);
  --text: #eef1f8;
  --text-dim: #aab2c6;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
html, body { height: 100%; width: 100%; overflow: hidden; background: #0a0e1a; color: var(--text); }
button { font-family: inherit; cursor: pointer; color: inherit; }

/* ---- Boot splash ---- */
#boot {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; background: radial-gradient(circle at 50% 40%, #1a2238, #05070f 80%);
  transition: opacity .6s ease;
}
#boot.done { opacity: 0; pointer-events: none; }
.boot-logo { font-size: 72px; animation: floaty 2.2s ease-in-out infinite; }
.boot-name { font-size: 26px; letter-spacing: 6px; font-weight: 300; color: #cdd6f0; }
.boot-bar { width: 180px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.12); overflow: hidden; }
.boot-bar-fill { height: 100%; width: 40%; border-radius: 4px; background: linear-gradient(90deg,#4f8cff,#a06bff); animation: load 1s ease-in-out infinite; }
@keyframes load { 0%{transform:translateX(-100%)} 100%{transform:translateX(350%)} }
@keyframes floaty { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-10px)} }

/* ---- Desktop ---- */
#desktop {
  position: absolute; inset: 0; bottom: var(--taskbar-h);
  background: linear-gradient(135deg,#1e3c72,#2a5298 40%,#7f53ac);
  transition: background .4s ease; overflow: hidden;
}
#desktop-icons {
  position: absolute; top: 14px; left: 14px;
  display: flex; flex-direction: column; flex-wrap: wrap; gap: 6px;
  max-height: calc(100% - 28px); align-content: flex-start;
}
.desk-icon {
  width: 92px; height: 92px; border: none; background: transparent; border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.6); transition: background .12s;
}
.desk-icon:hover { background: rgba(255,255,255,.14); }
.desk-icon:active { background: rgba(255,255,255,.24); }
.desk-icon-glyph { font-size: 38px; line-height: 1; filter: drop-shadow(0 2px 4px rgba(0,0,0,.4)); }
.desk-icon-label { font-size: 12px; text-align: center; max-width: 88px; }

/* ---- Windows ---- */
#windows { position: absolute; inset: 0; pointer-events: none; }
.window {
  position: absolute; pointer-events: auto;
  min-width: 320px; min-height: 220px;
  background: var(--glass-strong);
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--stroke); border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5), 0 2px 8px rgba(0,0,0,.3);
  display: flex; flex-direction: column; overflow: hidden;
  animation: winIn .16s ease;
}
@keyframes winIn { from { opacity: 0; transform: scale(.97) translateY(6px); } to { opacity: 1; transform: none; } }
.window.active { box-shadow: 0 26px 70px rgba(0,0,0,.62), 0 0 0 1px rgba(255,255,255,.05); }
.window.minimized { display: none; }
.window.maximized { left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important; border-radius: 0; }
.win-titlebar {
  height: 38px; flex: 0 0 38px; display: flex; align-items: center; gap: 8px; padding: 0 8px 0 12px;
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.02));
  border-bottom: 1px solid var(--stroke); cursor: grab; user-select: none;
}
.win-titlebar:active { cursor: grabbing; }
.win-icon { font-size: 16px; }
.win-title { flex: 1; font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-controls { display: flex; gap: 4px; }
.win-controls button {
  width: 26px; height: 26px; border: none; border-radius: 6px; background: rgba(255,255,255,.06);
  color: var(--text-dim); font-size: 13px; line-height: 1; display: grid; place-items: center; transition: background .12s, color .12s;
}
.win-controls button:hover { background: rgba(255,255,255,.16); color: #fff; }
.win-close:hover { background: #e5484d !important; color: #fff !important; }
.win-body { flex: 1; position: relative; overflow: auto; background: rgba(10,12,22,.35); }
.win-resize {
  position: absolute; right: 0; bottom: 0; width: 16px; height: 16px; cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, rgba(255,255,255,.3) 50%, rgba(255,255,255,.3) 60%, transparent 60%);
}
.app-error { padding: 24px; color: #ffb4b4; font-size: 14px; line-height: 1.5; }
.app-error code { display: block; margin-top: 8px; color: #ff8080; font-size: 12px; }

/* ---- Taskbar ---- */
#taskbar {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--taskbar-h); z-index: 5000;
  display: flex; align-items: center; gap: 6px; padding: 0 8px;
  background: var(--glass); backdrop-filter: blur(20px) saturate(150%); -webkit-backdrop-filter: blur(20px) saturate(150%);
  border-top: 1px solid var(--stroke);
}
#start-btn {
  height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 14px; border: none; border-radius: 8px;
  background: rgba(255,255,255,.08); color: #fff; font-size: 13px; font-weight: 600; transition: background .12s;
}
#start-btn:hover { background: rgba(255,255,255,.18); }
.start-glyph { font-size: 16px; }
#taskbar-running { flex: 1; display: flex; gap: 6px; overflow-x: auto; }
#taskbar-running::-webkit-scrollbar { height: 0; }
.task-btn {
  height: 36px; max-width: 180px; display: flex; align-items: center; gap: 7px; padding: 0 12px; border: none; border-radius: 8px;
  background: rgba(255,255,255,.06); color: var(--text-dim); font-size: 12px; transition: background .12s, color .12s;
  border-bottom: 2px solid transparent;
}
.task-btn:hover { background: rgba(255,255,255,.14); color: #fff; }
.task-btn.active { background: rgba(255,255,255,.16); color: #fff; border-bottom-color: var(--accent); }
.task-btn-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#taskbar-tray { display: flex; align-items: center; padding: 0 10px; color: var(--text); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---- Start menu ---- */
#start-menu {
  position: absolute; left: 8px; bottom: calc(var(--taskbar-h) + 8px); z-index: 6000;
  width: 340px; padding: 14px; border-radius: 14px;
  background: var(--glass-strong); backdrop-filter: blur(24px) saturate(150%); -webkit-backdrop-filter: blur(24px) saturate(150%);
  border: 1px solid var(--stroke); box-shadow: 0 20px 60px rgba(0,0,0,.55);
  animation: winIn .14s ease;
}
#start-menu.hidden { display: none; }
.start-header { font-size: 12px; color: var(--text-dim); margin-bottom: 12px; letter-spacing: .5px; }
.start-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.start-item {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 6px; border: none; border-radius: 10px;
  background: transparent; color: var(--text); font-size: 12px; transition: background .12s;
}
.start-item:hover { background: rgba(255,255,255,.12); }
.start-item-glyph { font-size: 30px; }

/* ---- Shared app UI helpers (available to all apps) ---- */
.app-pad { padding: 16px; }
.app-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; flex-wrap: wrap;
  background: rgba(255,255,255,.04); border-bottom: 1px solid var(--stroke);
}
.app-btn {
  padding: 6px 12px; border: 1px solid var(--stroke); border-radius: 7px; background: rgba(255,255,255,.06);
  color: var(--text); font-size: 12px; transition: background .12s;
}
.app-btn:hover { background: rgba(255,255,255,.16); }
.app-btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.hud {
  position: absolute; z-index: 3; color: #fff; font-size: 13px; pointer-events: none;
  text-shadow: 0 1px 4px rgba(0,0,0,.8);
}
.hud-tl { top: 10px; left: 12px; }
.hud-tr { top: 10px; right: 12px; text-align: right; }
.hud-center {
  top: 50%; left: 50%; transform: translate(-50%,-50%); text-align: center; font-size: 15px;
  background: rgba(0,0,0,.55); padding: 18px 24px; border-radius: 12px; pointer-events: auto;
}
.crosshair {
  position: absolute; top: 50%; left: 50%; width: 16px; height: 16px; transform: translate(-50%,-50%);
  z-index: 3; pointer-events: none;
}
.crosshair::before, .crosshair::after { content: ''; position: absolute; background: rgba(255,255,255,.85); }
.crosshair::before { left: 7px; top: 0; width: 2px; height: 16px; }
.crosshair::after { top: 7px; left: 0; height: 2px; width: 16px; }

@media (max-width: 620px) {
  .start-label, .task-btn-label { display: none; }
  .desk-icon { width: 76px; height: 84px; }
}
