:root {
  --taskbar-h: 48px;
  --glass: rgba(32, 32, 40, 0.78);
  --glass-light: rgba(255, 255, 255, 0.08);
  --text: #f3f3f5;
  --muted: #a9acb8;
  --accent: #4cc2ff;
  --win-bg: #ffffff;
  --win-text: #1b1b1f;
  --win-title: #f3f3f3;
  --radius: 10px;
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  overflow: hidden;
  color: var(--text);
  background: #0b2a4a radial-gradient(ellipse at 70% 80%, #1d6fb8 0%, #0e3e6e 35%, #081d36 75%) fixed;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* ---------- Desktop icons ---------- */
#desktop { position: absolute; inset: 0 0 var(--taskbar-h) 0; }
.icons {
  list-style: none; margin: 0; padding: 12px;
  display: grid; grid-auto-flow: column;
  grid-template-rows: repeat(auto-fill, 96px);
  grid-auto-columns: 88px; gap: 6px; height: 100%;
}
.icon {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 88px; padding: 6px 4px; border-radius: 6px; text-align: center;
  font-size: 12.5px; line-height: 1.2; text-shadow: 0 1px 3px rgba(0,0,0,.8);
  user-select: none;
}
.icon:hover { background: rgba(255,255,255,.10); }
.icon:focus-visible, .icon.selected { background: rgba(76,194,255,.28); outline: 1px solid rgba(76,194,255,.6); }
.glyph { font-size: 38px; line-height: 48px; height: 48px; }
.glyph img { width: 44px; height: 44px; object-fit: contain; }

/* ---------- Taskbar ---------- */
.taskbar {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--taskbar-h);
  display: flex; align-items: center; gap: 4px; padding: 0 8px;
  background: var(--glass); backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border-top: 1px solid rgba(255,255,255,.08); z-index: 10000;
}
.start-btn, .task {
  height: 40px; min-width: 40px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.start-btn { color: var(--accent); }
.start-btn:hover, .task:hover, .start-btn[aria-expanded="true"] { background: var(--glass-light); }
.tasks { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.task { padding: 0 10px; font-size: 13px; position: relative; max-width: 180px; }
.task span.label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task::after {
  content: ""; position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%);
  width: 6px; height: 3px; border-radius: 2px; background: var(--muted);
}
.task.active { background: var(--glass-light); }
.task.active::after { width: 16px; background: var(--accent); }
.clock { font-size: 12px; text-align: right; line-height: 1.3; padding: 0 6px; white-space: nowrap; }

/* ---------- Start menu ---------- */
.start-menu {
  position: fixed; left: 8px; bottom: calc(var(--taskbar-h) + 8px);
  width: min(560px, calc(100vw - 16px)); max-height: min(640px, calc(100vh - var(--taskbar-h) - 16px));
  display: flex; flex-direction: column;
  background: var(--glass); backdrop-filter: blur(30px) saturate(1.5);
  -webkit-backdrop-filter: blur(30px) saturate(1.5);
  border: 1px solid rgba(255,255,255,.1); border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(0,0,0,.5); z-index: 10001;
  animation: rise .14s ease-out;
}
.start-menu[hidden] { display: none; }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
#start-search {
  margin: 20px 24px 8px; padding: 9px 14px; border-radius: 20px;
  border: 1px solid rgba(255,255,255,.12); background: rgba(0,0,0,.25);
  color: var(--text); font: inherit; font-size: 14px; outline: none;
}
#start-search:focus { border-color: var(--accent); }
.start-heading { margin: 12px 32px 4px; font-size: 13px; font-weight: 600; }
.start-list {
  list-style: none; margin: 0; padding: 8px 20px 16px; overflow-y: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 4px;
}
.start-list .icon { width: auto; text-shadow: none; }
.start-list .icon small { color: var(--muted); font-size: 11px; display: none; }
.start-footer {
  display: flex; align-items: center; gap: 10px; padding: 14px 32px;
  border-top: 1px solid rgba(255,255,255,.08); background: rgba(0,0,0,.18);
  border-radius: 0 0 var(--radius) var(--radius); font-size: 13px;
}
.account-text { flex: 1; display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.account-text small { color: var(--muted); font-size: 11px; }
#start-user { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-action {
  color: var(--text); text-decoration: none; font-size: 12.5px;
  padding: 6px 12px; border-radius: 6px; background: rgba(255,255,255,.08);
}
.account-action:hover { background: rgba(255,255,255,.16); }
.account-btn {
  height: 40px; display: inline-flex; align-items: center; gap: 8px; padding: 0 10px;
  border-radius: 6px; color: var(--text); text-decoration: none; font-size: 12.5px; white-space: nowrap;
}
.account-btn:hover { background: var(--glass-light); }
.account-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.account-btn.signed-in .account-dot { background: #6ccb5f; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,.12); display: grid; place-items: center; }
.empty { color: var(--muted); font-size: 13px; padding: 12px; grid-column: 1 / -1; }

/* ---------- Windows ---------- */
.window {
  position: absolute; display: flex; flex-direction: column;
  min-width: 320px; min-height: 200px;
  background: var(--win-bg); color: var(--win-text);
  border-radius: 8px; overflow: hidden; resize: both;
  box-shadow: 0 12px 40px rgba(0,0,0,.45), 0 0 0 1px rgba(0,0,0,.25);
  animation: pop .12s ease-out;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.window.minimized { display: none; }
.window.maximized { inset: 0 !important; width: auto !important; height: auto !important; border-radius: 0; resize: none; }
.window:not(.focused) .titlebar { color: #888; }
.titlebar {
  height: 34px; flex: none; display: flex; align-items: center;
  background: var(--win-title); user-select: none; touch-action: none;
}
.titlebar .title { flex: 1; display: flex; align-items: center; gap: 8px; padding-left: 12px; font-size: 12.5px; overflow: hidden; white-space: nowrap; }
.titlebar button { width: 46px; height: 34px; display: grid; place-items: center; color: inherit; }
.titlebar button:hover { background: rgba(0,0,0,.08); }
.titlebar button.close:hover { background: #c42b1c; color: #fff; }
.titlebar svg { width: 10px; height: 10px; }
.window-body { flex: 1; position: relative; overflow: auto; }
.window-body iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.dragging iframe { pointer-events: none; }  /* keep drag smooth over iframes */

.welcome { padding: 24px 28px; line-height: 1.55; font-size: 14.5px; }
.welcome h1 { margin-top: 0; font-size: 22px; }

/* ---------- Phones ---------- */
@media (max-width: 640px) {
  .icons {
    grid-auto-flow: row; grid-template-rows: none;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    grid-auto-rows: 96px; height: auto; padding: 16px;
  }
  .icon { width: auto; }
  .window { inset: 0 !important; width: auto !important; height: auto !important; border-radius: 0; resize: none; }
  .titlebar button.max { display: none; }
  .start-menu { left: 8px; right: 8px; width: auto; }
  .account-btn #account-label { max-width: 90px; overflow: hidden; text-overflow: ellipsis; }
}

/* Profile photo (shown only once /avatars/<user> loads) */
.account-dot.has-photo { width: 22px; height: 22px; background-size: cover; background-position: center; box-shadow: 0 0 0 2px #6ccb5f; }
.avatar.has-photo { background-size: cover; background-position: center; color: transparent; }
