/* CelxOS: the shell every page runs inside.
   Left: the dock (apps). Bottom: the taskbar (terminal prompt, open window, tray).
   Middle: the desktop, where each page is a window (nav.js wraps the page's <main> in one). */

:root {
  --dock-w: 72px;
  --task-h: 46px;
  --os-line: #22222f;
  --os-line-2: #33334a;
  --os-panel: #0a0a12;
  --os-panel-2: #0d0d17;
}

body.os {
  padding: 0 0 var(--task-h) var(--dock-w);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Desktop wallpaper: faint grid + huge outlined wordmark, behind every window */
.os-wall {
  position: fixed;
  inset: 0 0 var(--task-h) var(--dock-w);
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(0, 229, 255, 0.035) 1px, transparent 1px) 0 0 / 48px 48px,
    linear-gradient(90deg, rgba(0, 229, 255, 0.035) 1px, transparent 1px) 0 0 / 48px 48px;
  mask-image: radial-gradient(ellipse at 60% 40%, #000 30%, transparent 85%);
  -webkit-mask-image: radial-gradient(ellipse at 60% 40%, #000 30%, transparent 85%);
}
.os-wall-word {
  position: fixed;
  right: 24px;
  bottom: calc(var(--task-h) + 6px);
  z-index: 0;
  pointer-events: none;
  font-family: "Unbounded", system-ui, sans-serif;
  font-weight: 900;
  font-size: clamp(3rem, 11vw, 11rem);
  line-height: 0.8;
  letter-spacing: -0.03em;
  color: transparent;
  -webkit-text-stroke: 1px rgba(255, 255, 255, 0.05);
  user-select: none;
}

/* ---------------- Dock ---------------- */
.os-dock {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  width: var(--dock-w);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 0 calc(var(--task-h) + 12px);
  background: #05050a;
  border-right: 1px solid var(--os-line);
  font-family: "JetBrains Mono", ui-monospace, monospace;
}
.os-start {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin-bottom: 10px;
  border: 1px solid var(--os-line-2);
  border-radius: 4px;
  background: #07070d;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.os-start svg { width: 30px; height: 30px; }
.os-start:hover, .os-start[aria-expanded="true"] { border-color: #00e5ff; box-shadow: -3px 0 0 rgba(0, 229, 255, 0.4), 3px 0 0 rgba(255, 43, 214, 0.4); }
.os-dock .sep { width: 28px; height: 1px; margin: 8px 0; background: var(--os-line-2); }
.os-app {
  position: relative;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  color: #8a8aa0;
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
.os-app svg { width: 21px; height: 21px; }
.os-app:hover { color: #f2f2f5; background: rgba(255, 255, 255, 0.04); }
.os-app.on { color: #00e5ff; background: rgba(0, 229, 255, 0.08); }
.os-app.on::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  background: #00e5ff;
  box-shadow: 0 0 10px #00e5ff, 2px 0 0 #ff2bd6;
}
.os-app:focus-visible, .os-start:focus-visible { outline: 2px solid #00e5ff; outline-offset: 2px; }
/* label that slides out on hover */
.os-app .tip {
  position: absolute;
  left: calc(100% + 14px);
  top: 50%;
  padding: 6px 10px;
  border: 1px solid var(--os-line-2);
  border-radius: 3px;
  background: var(--os-panel);
  color: #f2f2f5;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-6px, -50%);
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
}
.os-app .tip small { margin-left: 8px; color: #6f6f82; }
.os-app:hover .tip, .os-app:focus-visible .tip { opacity: 1; transform: translate(0, -50%); }
.os-dock .grow { flex: 1; }
.os-dock .ver { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 0.6rem; letter-spacing: 0.3em; color: #3a3a52; }

/* ---------------- Taskbar ---------------- */
.os-task {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 65;
  height: var(--task-h);
  display: flex;
  align-items: stretch;
  background: #05050a;
  border-top: 1px solid var(--os-line);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.78rem;
}
.os-prompt {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 0 20px;
  border-right: 1px solid var(--os-line);
  cursor: text;
}
.os-prompt .ps { color: #00e5ff; white-space: nowrap; }
.os-prompt .ps b { color: #f2f2f5; font-weight: 400; }
.os-prompt input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: none;
  color: #f2f2f5;
  font: inherit;
  caret-color: #00e5ff;
}
.os-prompt input::placeholder { color: #44445a; }
.os-prompt kbd { padding: 2px 6px; border: 1px solid var(--os-line-2); border-radius: 2px; font: inherit; font-size: 0.66rem; color: #6f6f82; }
.os-tasks { display: flex; align-items: stretch; border-right: 1px solid var(--os-line); }
.os-taskbtn {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 240px;
  padding: 0 16px;
  border: 0;
  border-top: 2px solid transparent;
  background: none;
  color: #b9b9c6;
  font: inherit;
  white-space: nowrap;
  cursor: pointer;
}
.os-taskbtn svg { width: 15px; height: 15px; color: #00e5ff; flex: none; }
.os-taskbtn span { overflow: hidden; text-overflow: ellipsis; }
.os-taskbtn:hover { background: rgba(255, 255, 255, 0.03); color: #f2f2f5; }
.os-taskbtn.on { border-top-color: #00e5ff; background: rgba(0, 229, 255, 0.06); color: #f2f2f5; }
.os-taskbtn.min { color: #55556a; }
.os-taskbtn.min svg { color: #55556a; }
.os-tray { display: flex; align-items: center; gap: 4px; padding: 0 10px 0 6px; }
.os-tray .ti {
  position: relative;
  height: 34px;
  min-width: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 8px;
  border: 0;
  border-radius: 3px;
  background: none;
  color: #b9b9c6;
  font: inherit;
  cursor: pointer;
}
.os-tray .ti:hover { background: rgba(255, 255, 255, 0.05); color: #f2f2f5; }
.os-tray .ti svg { width: 16px; height: 16px; }
.os-tray .dot { width: 7px; height: 7px; background: #3ef0a1; box-shadow: 0 0 8px #3ef0a1; }
.os-tray .dot.off { background: #ff4f6d; box-shadow: none; }
.os-tray .dot.wait { background: #6f6f82; box-shadow: none; }
.os-tray .clock { display: grid; line-height: 1.15; text-align: right; font-variant-numeric: tabular-nums; cursor: default; }
.os-tray .clock b { color: #f2f2f5; font-weight: 600; }
.os-tray .clock small { font-size: 0.6rem; color: #6f6f82; letter-spacing: 0.1em; }
.bell-count {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  display: grid;
  place-items: center;
  border-radius: 2px;
  background: #00e5ff;
  color: #07070d;
  font: 800 0.56rem/1 "JetBrains Mono", monospace;
}

/* Terminal output sheet, opens above the prompt */
.os-term {
  position: fixed;
  left: var(--dock-w);
  bottom: var(--task-h);
  z-index: 64;
  width: min(720px, calc(100vw - var(--dock-w)));
  max-height: min(420px, 60vh);
  display: none;
  flex-direction: column;
  background: rgba(6, 6, 11, 0.97);
  border: 1px solid var(--os-line-2);
  border-bottom: 0;
  border-left: 0;
  box-shadow: 0 -30px 80px -30px rgba(0, 0, 0, 0.9), -3px 0 0 rgba(0, 229, 255, 0.25);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.8rem;
}
.os-term.open { display: flex; }
.os-term-head { display: flex; justify-content: space-between; padding: 9px 16px; border-bottom: 1px solid var(--os-line); font-size: 0.66rem; letter-spacing: 0.2em; text-transform: uppercase; color: #6f6f82; }
.os-term-head button { border: 0; background: none; color: #6f6f82; font: inherit; cursor: pointer; }
.os-term-head button:hover { color: #f2f2f5; }
.os-term-out { flex: 1; overflow-y: auto; padding: 12px 16px 14px; line-height: 1.75; color: #b9b9c6; white-space: pre-wrap; }
.os-term-out .c { color: #00e5ff; }
.os-term-out .w { color: #f2f2f5; }
.os-term-out .g { color: #3ef0a1; }
.os-term-out .r { color: #ff4f6d; }
.os-term-out .d { color: #6f6f82; }
.os-term-out a { color: #00e5ff; }

/* ---------------- Start menu ---------------- */
.os-menu {
  position: fixed;
  left: calc(var(--dock-w) + 10px);
  top: 12px;
  z-index: 70;
  width: min(560px, calc(100vw - var(--dock-w) - 20px));
  display: none;
  grid-template-columns: 1fr 1fr;
  background: #08080e;
  border: 1px solid var(--os-line-2);
  border-radius: 4px;
  box-shadow: -4px 0 0 rgba(0, 229, 255, 0.3), 4px 0 0 rgba(255, 43, 214, 0.3), 0 40px 100px -20px rgba(0, 0, 0, 0.95);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  overflow: hidden;
}
.os-menu.open { display: grid; animation: menu-in 0.25s cubic-bezier(.2, .8, .2, 1); }
@keyframes menu-in { from { transform: translateX(-8px); } }
.os-menu-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--os-line);
  background: linear-gradient(90deg, rgba(0, 229, 255, 0.07), transparent 70%);
}
.os-menu-head svg { width: 40px; height: 40px; }
.os-menu-head b { display: block; font-family: "Unbounded", system-ui, sans-serif; font-weight: 900; font-size: 1.15rem; color: #f2f2f5; }
.os-menu-head small { font-size: 0.66rem; letter-spacing: 0.4em; color: #6f6f82; }
.os-menu-col { padding: 14px; }
.os-menu-col + .os-menu-col { border-left: 1px solid var(--os-line); }
.os-menu h4 { padding: 4px 8px 10px; font-size: 0.62rem; font-weight: 700; letter-spacing: 0.28em; text-transform: uppercase; color: #6f6f82; }
.os-menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 8px;
  border-radius: 3px;
  color: #b9b9c6;
  text-decoration: none;
  font-size: 0.8rem;
}
.os-menu a svg { width: 17px; height: 17px; flex: none; color: #00e5ff; }
.os-menu a span small { display: block; font-size: 0.66rem; color: #6f6f82; }
.os-menu a:hover, .os-menu a:focus-visible { background: rgba(0, 229, 255, 0.07); color: #f2f2f5; outline: none; }
.os-menu-foot { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; padding: 12px 22px; border-top: 1px solid var(--os-line); font-size: 0.68rem; color: #6f6f82; }
.os-menu-foot .soc { display: flex; gap: 6px; }
.os-menu-foot .soc a { padding: 7px; }
.os-menu-foot .soc a svg { width: 15px; height: 15px; color: #b9b9c6; }

/* ---------------- Window (wraps each page's <main>) ---------------- */
.win {
  position: relative;
  z-index: 1;
  margin: 18px 18px 18px 18px;
  min-height: calc(100vh - var(--task-h) - 36px);
  display: flex;
  flex-direction: column;
  background: rgba(8, 8, 14, 0.94);
  border: 1px solid var(--os-line-2);
  border-radius: 6px;
  box-shadow: 0 50px 120px -40px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(0, 0, 0, 0.6);
  animation: win-open 0.4s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes win-open { from { opacity: 0; transform: scale(0.985) translateY(10px); } }
body.win-max .win { margin: 0; border-radius: 0; border-width: 0; min-height: calc(100vh - var(--task-h)); }
.win-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 0 8px 0 14px;
  background: rgba(10, 10, 18, 0.96);
  border-bottom: 1px solid var(--os-line);
  border-radius: 6px 6px 0 0;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.76rem;
  user-select: none;
}
body.win-max .win-bar { border-radius: 0; }
.win-bar .ico { width: 16px; height: 16px; color: #00e5ff; flex: none; }
.win-path { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #6f6f82; }
.win-path b { color: #f2f2f5; font-weight: 500; }
.win-path i { font-style: normal; color: #00e5ff; }
.win-btns { display: flex; gap: 2px; }
.win-btns a, .win-btns button {
  width: 34px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 3px;
  background: none;
  color: #8a8aa0;
  cursor: pointer;
  text-decoration: none;
}
.win-btns svg { width: 13px; height: 13px; }
.win-btns a:hover, .win-btns button:hover { background: rgba(255, 255, 255, 0.06); color: #f2f2f5; }
.win-btns .x:hover { background: #ff4f6d; color: #07070d; }
.win-body { position: relative; flex: 1; min-width: 0; }
body.os .win-body > main { width: auto; max-width: none; margin: 0; padding: 34px 40px 60px; animation: none; }
@media (max-width: 760px) { body.os .win-body > main { padding: 22px 16px 50px; } }

/* ---------------- Notifications panel ---------------- */
.bell-panel {
  position: fixed;
  right: 10px;
  bottom: calc(var(--task-h) + 8px);
  z-index: 70;
  width: min(380px, calc(100vw - 20px));
  display: none;
  background: var(--os-panel);
  border: 1px solid var(--os-line-2);
  border-radius: 4px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.95);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  overflow: hidden;
}
.bell-panel.open { display: block; animation: menu-in 0.2s; }
.bell-head { padding: 12px 16px; border-bottom: 1px solid var(--os-line); color: #00e5ff; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.28em; text-transform: uppercase; }
.bell-panel ul { list-style: none; margin: 0; padding: 6px; max-height: min(420px, 60vh); overflow: auto; }
.bell-item { display: grid; grid-template-columns: 46px 1fr; gap: 12px; padding: 10px; border-left: 2px solid transparent; border-radius: 2px; color: #b9b9c6; text-decoration: none; }
a.bell-item:hover { background: rgba(255, 255, 255, 0.03); }
.bell-item strong { display: block; color: #f2f2f5; font-weight: 600; font-size: 0.82rem; line-height: 1.4; }
.bell-item small { display: block; margin-top: 3px; font-size: 0.72rem; line-height: 1.45; }
.bell-item.unread { background: rgba(0, 229, 255, 0.05); border-left-color: #00e5ff; }
.bell-ic { align-self: start; padding: 3px 0; border: 1px solid var(--os-line); border-radius: 2px; color: #00e5ff; font-size: 0.56rem; font-weight: 700; text-align: center; }
.bell-empty { padding: 22px; text-align: center; color: #b9b9c6; font-size: 0.82rem; }

/* ---------------- Phones: dock moves to the bottom, prompt becomes a button ---------------- */
@media (max-width: 760px) {
  :root { --dock-w: 0px; --task-h: 58px; }
  .os-dock {
    inset: auto 0 0 0;
    width: auto;
    height: var(--task-h);
    flex-direction: row;
    justify-content: space-around;
    gap: 0;
    padding: 0 6px;
    border-right: 0;
    border-top: 1px solid var(--os-line);
    z-index: 66;
  }
  .os-start { width: 42px; height: 42px; margin: 0; }
  .os-start svg { width: 24px; height: 24px; }
  .os-app { width: 44px; height: 44px; }
  .os-app.on::before { left: 10px; right: 10px; top: auto; bottom: -7px; width: auto; height: 3px; }
  .os-app .tip, .os-dock .sep, .os-dock .grow, .os-dock .ver, .os-dock .portal-app { display: none; }
  .os-task { top: 0; bottom: auto; height: 44px; border-top: 0; border-bottom: 1px solid var(--os-line); }
  body.os { padding: 44px 0 var(--task-h) 0; }
  .os-wall { inset: 44px 0 var(--task-h) 0; }
  .os-prompt { padding: 0 12px; }
  .os-prompt .ps { display: none; }
  .os-prompt kbd, .os-tasks { display: none; }
  .os-tray .clock small { display: none; }
  .os-term { left: 0; top: 44px; bottom: auto; width: 100%; max-height: 55vh; border: 0; border-bottom: 1px solid var(--os-line-2); }
  .os-menu { left: 8px; right: 8px; top: auto; bottom: calc(var(--task-h) + 8px); width: auto; grid-template-columns: 1fr; }
  .os-menu-col + .os-menu-col { border-left: 0; border-top: 1px solid var(--os-line); }
  .win { margin: 0; border-radius: 0; border-width: 0; min-height: calc(100vh - 44px - var(--task-h)); }
  .win-bar { top: 44px; border-radius: 0; }
  .bell-panel { top: 52px; bottom: auto; }
  .os-wall-word { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .win, .os-menu.open, .bell-panel.open { animation: none; }
}
.os-start img { width: 34px; height: 34px; }
.os-menu-head img { width: 40px; height: 40px; }
