/* ------------------------------------------------------------------ *
 * NightShift Desktop
 * ------------------------------------------------------------------ */

.desktop-active #starfield {
  z-index: 0; /* stays put — the desktop overlay sits above it, using it as wallpaper */
}

.nightos {
  position: fixed;
  inset: 0;
  z-index: 500;
  overflow: hidden;
  font-family: var(--font-sans);
  color: var(--text-primary);
  user-select: none;
}

/* ---- Desktop icons ---- */

.nightos-icons {
  position: absolute;
  inset: 0;
  padding: 1rem;
}

.nightos-icon {
  position: absolute;
  left: 12px;
  width: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: default;
  padding: 0.5rem 0.25rem;
  border-radius: var(--radius-sm);
}

.nightos-icon:hover,
.nightos-icon:focus-visible {
  background: rgba(255, 255, 255, 0.06);
}

.nightos-icon.dragging {
  opacity: 0.75;
  z-index: 5;
  cursor: grabbing;
  background: rgba(255, 255, 255, 0.1);
}

.nightos-icon-glyph {
  font-size: 2rem;
  line-height: 1;
}

.nightos-icon-label {
  font-size: 0.72rem;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

/* ---- Windows ---- */

.nightos-window-layer {
  position: absolute;
  inset: 0;
  pointer-events: none; /* the empty layer itself shouldn't catch clicks — only actual windows should */
}

.nw-window {
  pointer-events: auto;
  position: absolute;
  display: flex;
  flex-direction: column;
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 260px;
  min-height: 160px;
}

.nw-window.nw-focused {
  border-color: var(--accent);
}

/* Opt-in for apps whose own content already draws a clean edge (e.g. the
   vendored Pinball embed) — the 1px frame + glass shadow just competed
   with it visually. Titlebar (drag/close/minimize) stays; only the outer
   frame goes. */
.nw-window--no-border {
  border: none;
  box-shadow: none;
}

.nw-window.nw-minimized {
  display: none;
}

.nw-window.nw-maximized {
  left: 0 !important;
  top: 0 !important;
  width: 100% !important;
  height: calc(100% - 52px) !important;
  border-radius: 0;
}

.nw-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.5rem 0 0.75rem;
  height: 34px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--glass-border);
  cursor: default;
}

.nw-focused .nw-titlebar {
  background: var(--accent-dim);
}

.nw-title {
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nw-controls {
  display: flex;
  gap: 0.2rem;
  flex-shrink: 0;
}

.nw-btn {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
}

.nw-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.nw-close:hover {
  background: var(--danger);
  color: white;
}

.nw-content {
  flex: 1;
  overflow: auto;
  position: relative;
}

.nw-resize-handle {
  position: absolute;
}

.nw-resize-e {
  top: 0;
  right: 0;
  width: 6px;
  height: 100%;
  cursor: ew-resize;
}

.nw-resize-s {
  bottom: 0;
  left: 0;
  width: 100%;
  height: 6px;
  cursor: ns-resize;
}

.nw-resize-se {
  bottom: 0;
  right: 0;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
}

.nw-window.nw-maximized .nw-resize-handle {
  display: none;
}

/* ---- Taskbar ---- */

.nightos-taskbar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.75rem;
  border-top: 1px solid var(--glass-border);
  border-radius: 0;
}

.nightos-launcher {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.8rem;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  flex-shrink: 0;
}

.nightos-taskbar-apps {
  flex: 1;
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
}

.taskbar-app {
  background: var(--hover-bg, rgba(255, 255, 255, 0.05));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
}

.taskbar-app-active {
  color: var(--text-primary);
  border-color: var(--accent);
}

.nightos-taskbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.nightos-clock {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.nightos-logout {
  background: none;
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 0.9rem;
}

.nightos-logout:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.nightos-dnd { background: none; border: 1px solid var(--glass-border); color: var(--text-muted); border-radius: 50%; width: 30px; height: 30px; cursor: pointer; font-size: .85rem; }
.nightos-dnd.active { color: var(--warning); border-color: var(--warning); background: rgba(251,191,36,.12); }

/* ---- Start menu ---- */

.nightos-start-menu {
  position: absolute;
  bottom: 60px;
  left: 0.75rem;
  min-width: 200px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--glass-shadow);
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nightos-start-item {
  text-align: left;
  background: none;
  border: none;
  color: var(--text-primary);
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
}

.nightos-start-item:hover {
  background: var(--accent-dim);
}

.nightos-context-menu {
  position: fixed;
  z-index: 9500;
  min-width: 200px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--glass-shadow);
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nightos-context-menu button {
  text-align: left;
  background: none;
  border: none;
  color: var(--text-primary);
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  cursor: pointer;
  font-family: var(--font-sans);
}

.nightos-context-menu button:hover {
  background: var(--accent-dim);
}

/* ---- Notes app ---- */

.notes-app {
  display: flex;
  height: 100%;
  font-size: 0.85rem;
}

.notes-sidebar {
  width: 150px;
  flex-shrink: 0;
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  padding: 0.5rem;
  gap: 0.4rem;
}

.notes-new-btn {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.4rem;
  font-size: 0.78rem;
  cursor: pointer;
}

.notes-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.notes-list li {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.notes-item {
  flex: 1;
  text-align: left;
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 0.35rem 0.4rem;
  border-radius: 5px;
  font-size: 0.76rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.notes-item:hover,
.notes-item-active {
  background: var(--accent-dim);
  color: var(--text-primary);
}

.notes-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0 0.25rem;
}

.notes-delete:hover {
  color: var(--danger);
}

.notes-empty {
  color: var(--text-muted);
  font-size: 0.76rem;
  padding: 0.35rem;
}

.notes-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.notes-filename {
  border: none;
  border-bottom: 1px solid var(--glass-border);
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.5rem 0.75rem;
}

.notes-filename:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.03);
}

.notes-editor {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  padding: 0.75rem;
  resize: none;
}

.notes-editor:focus {
  outline: none;
}

.notes-status {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 0.2rem 0.75rem 0.4rem;
  text-align: right;
}

/* ---- Code app — shares Notes' visual language, plus a line-number gutter ---- */

.code-app { display: flex; height: 100%; font-size: 0.85rem; }
.code-sidebar { width: 150px; flex-shrink: 0; border-right: 1px solid var(--glass-border); display: flex; flex-direction: column; padding: 0.5rem; gap: 0.4rem; }
.code-new-btn { background: var(--accent-dim); border: 1px solid var(--accent); color: var(--accent); border-radius: var(--radius-sm); padding: 0.4rem; font-size: 0.78rem; cursor: pointer; }
.code-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 0.15rem; }
.code-list li { display: flex; align-items: center; gap: 0.15rem; }
.code-item { flex: 1; text-align: left; background: none; border: none; color: var(--text-secondary); padding: 0.35rem 0.4rem; border-radius: 5px; font-size: 0.76rem; font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.code-item:hover, .code-item-active { background: var(--accent-dim); color: var(--text-primary); }
.code-delete { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.85rem; padding: 0 0.25rem; }
.code-delete:hover { color: var(--danger); }
.code-empty { color: var(--text-muted); font-size: 0.76rem; padding: 0.35rem; }

.code-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.code-toolbar { display: flex; align-items: center; border-bottom: 1px solid var(--glass-border); }
.code-filename { flex: 1; border: none; background: transparent; color: var(--text-primary); font-family: var(--font-mono); font-size: 0.8rem; padding: 0.5rem 0.75rem; }
.code-filename:focus { outline: none; background: rgba(255, 255, 255, 0.03); }
.code-download { background: none; border: none; color: var(--accent); font-size: 0.72rem; cursor: pointer; padding: 0.5rem 0.75rem; }
.code-download:disabled { color: var(--text-muted); cursor: not-allowed; }

.code-editor-wrap { flex: 1; display: flex; overflow: hidden; min-height: 0; }
.code-gutter {
  flex-shrink: 0;
  width: 2.6rem;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  padding: 0.75rem 0.4rem 0.75rem 0;
  text-align: right;
  white-space: pre;
  user-select: none;
}
.code-editor {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  padding: 0.75rem;
  resize: none;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}
.code-editor:focus { outline: none; }
.code-status { font-size: 0.7rem; color: var(--text-muted); padding: 0.2rem 0.75rem 0.4rem; text-align: right; }

.notes-status { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.notes-download { border: 1px solid var(--glass-border); border-radius: 5px; background: transparent; color: var(--text-secondary); padding: .18rem .45rem; font-size: .68rem; cursor: pointer; }
.notes-download:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }.notes-download:disabled { opacity: .35; cursor: default; }

/* Kept in lockstep with MIN_DESKTOP_WIDTH / MIN_DESKTOP_HEIGHT in
   js/terminal.js. If these two ever disagree, the gap is a blank screen:
   the JS lets the desktop launch while the CSS hides it, leaving the
   dashboard hidden and nothing in its place. */
@media (max-width: 719px), (max-height: 479px) {
  .nightos { display: none; }
}

/* ---- File Manager app ---- */

.filemgr-app {
  display: flex;
  flex-direction: column;
  height: 100%;
  font-size: 0.85rem;
}

.filemgr-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.filemgr-up {
  background: none;
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  color: var(--text-secondary);
  width: 26px;
  height: 26px;
  cursor: pointer;
  flex-shrink: 0;
}

.filemgr-up:disabled {
  opacity: 0.3;
  cursor: default;
}

.filemgr-breadcrumb {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  overflow-x: auto;
  white-space: nowrap;
}

.filemgr-crumb {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.78rem;
  padding: 0.15rem 0.35rem;
  border-radius: 5px;
  cursor: pointer;
}

.filemgr-crumb:hover {
  background: var(--accent-dim);
  color: var(--text-primary);
}

.filemgr-sep {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.filemgr-actions {
  display: flex;
  gap: 0.3rem;
  flex-shrink: 0;
}

.filemgr-actions button {
  background: none;
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.78rem;
  padding: 0.2rem 0.45rem;
  cursor: pointer;
}

.filemgr-actions button:hover:not(:disabled) {
  background: var(--accent-dim);
  color: var(--text-primary);
  border-color: var(--accent);
}

.filemgr-actions button:disabled {
  opacity: 0.35;
  cursor: default;
}

.filemgr-actions .hidden {
  display: none;
}

.filemgr-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.filemgr-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-primary);
  padding: 0.4rem 0.5rem;
  cursor: pointer;
  font-size: 0.82rem;
}

.filemgr-item:hover {
  background: var(--hover-bg, rgba(255, 255, 255, 0.05));
}

.filemgr-item-selected {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.filemgr-item-icon {
  flex-shrink: 0;
}

.filemgr-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filemgr-item-editing {
  cursor: default;
}

.filemgr-item-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  padding: 0.15rem 0.35rem;
}

.filemgr-item-input:focus {
  outline: none;
}

.filemgr-empty {
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 1rem;
  text-align: center;
}

.filemgr-status { min-height: 1.7rem; padding: .35rem .7rem; border-top: 1px solid var(--glass-border); color: var(--success); font-size: .72rem; }

/* ---- Desktop Terminal app ---- */

.desktop-terminal { display: flex; flex-direction: column; height: 100%; background: #080b09; color: #c8f7d9; font-family: var(--font-mono); font-size: .81rem; }
.desktop-terminal-output { flex: 1; overflow: auto; padding: .85rem; line-height: 1.55; white-space: pre-wrap; }
.desktop-terminal-line { min-height: 1.3em; }
.desktop-terminal-line.command { color: #7ef0ac; }.desktop-terminal-line.banner { color: #a78bfa; }.desktop-terminal-line.muted { color: #7c8c82; margin-bottom: .65rem; }.desktop-terminal-line.error { color: #f87171; }.desktop-terminal-line.info { color: #60a5fa; }
.desktop-terminal-form { display: flex; gap: .5rem; align-items: center; padding: .7rem .85rem; border-top: 1px solid #1a3021; color: #7ef0ac; }
.desktop-terminal-form label { white-space: nowrap; font-size: .76rem; }.desktop-terminal-form input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: #e5fff0; font: inherit; }

/* ---- System app ---- */
.system-app { padding: 1rem; font-size: .83rem; }.system-hero { display: flex; gap: .8rem; align-items: center; padding-bottom: 1rem; border-bottom: 1px solid var(--glass-border); }.system-hero > span { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 11px; background: var(--accent-dim); color: var(--accent); font-size: 1.5rem; }.system-hero strong, .system-hero small { display: block; }.system-hero small { margin-top: .18rem; color: var(--text-muted); }
.system-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; margin: 1rem 0; }.system-grid div { padding: .6rem; border: 1px solid var(--glass-border); border-radius: 7px; background: rgba(255,255,255,.025); }.system-grid span, .system-grid strong { display: block; }.system-grid span { color: var(--text-muted); font-size: .7rem; }.system-grid strong { margin-top: .2rem; font-size: .76rem; font-weight: 500; }
.system-guide { padding: .75rem; border-radius: 7px; background: var(--accent-dim); }.system-guide h3 { margin: 0 0 .35rem; font-size: .88rem; }.system-guide p { margin: 0; color: var(--text-secondary); line-height: 1.45; }.system-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .65rem; }.system-actions button { border: 1px solid var(--accent); border-radius: 5px; background: transparent; color: var(--accent); padding: .3rem .5rem; font-size: .72rem; cursor: pointer; }.system-actions button:hover { background: var(--accent); color: var(--on-accent-text); }.system-hint { color: var(--text-muted); margin: .8rem 0 0; font-size: .72rem; }

/* ---- Trophy Room app ---- */
.trophy-app { padding: 1rem; font-size: .83rem; height: 100%; display: flex; flex-direction: column; }
.trophy-hero { display: flex; gap: .8rem; align-items: center; padding-bottom: 1rem; border-bottom: 1px solid var(--glass-border); }
.trophy-hero > span { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 11px; background: var(--accent-dim); color: var(--accent); font-size: 1.5rem; }
.trophy-hero strong, .trophy-hero small { display: block; }
.trophy-hero small { margin-top: .18rem; color: var(--text-muted); }
.trophy-replay { margin: .8rem 0; padding: .5rem .7rem; border: 1px solid var(--accent); border-radius: 7px; background: var(--accent-dim); color: var(--accent); font-size: .78rem; cursor: pointer; font-family: var(--font-sans); }
.trophy-replay:hover { background: var(--accent); color: var(--on-accent-text); }
.trophy-grid { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: .5rem; }
.trophy-item { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .3rem; padding: .55rem .3rem; border: 1px solid var(--glass-border); border-radius: 8px; background: rgba(255,255,255,.025); opacity: .55; }
.trophy-item.unlocked { opacity: 1; border-color: rgba(251, 191, 36, 0.35); background: rgba(251, 191, 36, 0.06); }
.trophy-icon { font-size: 1.4rem; line-height: 1; }
.trophy-title { font-size: .64rem; color: var(--text-secondary); line-height: 1.25; }
.trophy-item.unlocked .trophy-title { color: var(--text-primary); }

/* ---- Minesweeper ---- */
.mine-app { padding: .75rem; display: flex; flex-direction: column; height: 100%; font-size: .8rem; box-sizing: border-box; }
.mine-toolbar { display: flex; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.mine-diff { flex: 1; background: rgba(255,255,255,.04); border: 1px solid var(--glass-border); border-radius: 5px; color: var(--text-primary); padding: .3rem; font-size: .74rem; }
.mine-counter { font-family: var(--font-mono); background: #111; color: #ef4444; padding: .25rem .5rem; border-radius: 4px; letter-spacing: .1em; min-width: 2.6em; text-align: center; }
.mine-face { font-size: 1.1rem; background: rgba(255,255,255,.05); border: 1px solid var(--glass-border); border-radius: 6px; width: 34px; height: 34px; cursor: pointer; }
.mine-board-wrap { overflow: auto; border: 1px solid var(--glass-border); border-radius: 6px; padding: .4rem; flex: 1; background: rgba(0,0,0,.15); }
.mine-board { display: grid; gap: 1px; width: max-content; }
.mine-cell { width: 22px; height: 22px; padding: 0; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.06); font-size: .7rem; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-primary); }
.mine-cell:hover { background: rgba(255,255,255,.1); }
.mine-cell.revealed { background: rgba(0,0,0,.2); cursor: default; }
.mine-cell.boom { background: rgba(239,68,68,.4); }
.mine-cell[data-count="1"] { color: #60a5fa; }
.mine-cell[data-count="2"] { color: #34d399; }
.mine-cell[data-count="3"] { color: #f87171; }
.mine-cell[data-count="4"] { color: #a78bfa; }
.mine-cell[data-count="5"] { color: #fbbf24; }
.mine-cell[data-count="6"] { color: #22d3ee; }
.mine-cell[data-count="7"] { color: #f472b6; }
.mine-cell[data-count="8"] { color: #cbd5e1; }
.mine-hint { margin: .5rem 0 0; font-size: .68rem; color: var(--text-muted); text-align: center; }

/* ---- Blackjack ---- */
.bj-app { padding: .9rem; display: flex; flex-direction: column; height: 100%; box-sizing: border-box; font-size: .82rem; }
.bj-table { flex: 1; display: flex; flex-direction: column; justify-content: space-around; background: rgba(6,60,30,.25); border: 1px solid var(--glass-border); border-radius: 10px; padding: .8rem; }
.bj-row { display: flex; flex-direction: column; gap: .4rem; }
.bj-label { font-size: .75rem; color: var(--text-muted); display: flex; align-items: center; gap: .4rem; }
.bj-hand-value { font-family: var(--font-mono); color: var(--accent); font-weight: 600; }
.bj-hand { display: flex; gap: .3rem; min-height: 3.4rem; flex-wrap: wrap; }
.bj-card { width: 2.4rem; height: 3.3rem; border-radius: 5px; background: #fff; color: #111; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.bj-card.red { color: #dc2626; }
.bj-card.hidden-card { background: linear-gradient(135deg, #4c1d95, #6d28d9); color: transparent; }
.bj-message { min-height: 1.4rem; margin: .6rem 0; text-align: center; font-size: .8rem; color: var(--text-secondary); }
.bj-bet-controls, .bj-play-controls { display: flex; gap: .5rem; align-items: center; justify-content: center; }
.bj-chips { font-family: var(--font-mono); }
.bj-bet-input { width: 5rem; background: rgba(255,255,255,.05); border: 1px solid var(--glass-border); border-radius: 5px; color: var(--text-primary); padding: .35rem; font-family: var(--font-mono); }
.bj-controls button { border: 1px solid var(--accent); border-radius: 6px; background: transparent; color: var(--accent); padding: .4rem .7rem; font-size: .78rem; cursor: pointer; font-family: var(--font-sans); }
.bj-controls button:hover:not(:disabled) { background: var(--accent); color: var(--on-accent-text); }
.bj-controls button:disabled { opacity: .4; cursor: not-allowed; }

/* ---- Spider Solitaire ---- */
.sol-app { display: flex; flex-direction: column; height: 100%; box-sizing: border-box; padding: .7rem; font-size: .78rem; }
.sol-toolbar { display: flex; align-items: center; gap: .8rem; margin-bottom: .5rem; flex-wrap: wrap; }
.sol-toolbar button { border: 1px solid var(--accent); border-radius: 6px; background: transparent; color: var(--accent); padding: .35rem .6rem; font-size: .74rem; cursor: pointer; font-family: var(--font-sans); }
.sol-toolbar button:hover:not(:disabled) { background: var(--accent); color: var(--on-accent-text); }
.sol-toolbar button:disabled { opacity: .4; cursor: not-allowed; }
.sol-stat { color: var(--text-muted); }
.sol-message { min-height: 1.2rem; margin-bottom: .5rem; color: var(--text-secondary); }
/* Classic green-felt table, not a transparent tint over the window's own
   dark background — this is the single biggest thing that made the old
   board read as "a plain rectangle" instead of a card table. */
.sol-board {
  flex: 1;
  display: flex;
  gap: .45rem;
  overflow: auto;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255,255,255,.05), transparent 60%),
    linear-gradient(160deg, #1f6b3f, #124023 70%, #0d3419);
  border: 1px solid rgba(0,0,0,.4);
  border-radius: 8px;
  padding: .7rem .6rem;
  box-shadow: inset 0 2px 10px rgba(0,0,0,.35);
}
.sol-column { position: relative; width: 64px; flex-shrink: 0; cursor: pointer; }

.sol-card {
  position: absolute;
  left: 0;
  width: 58px;
  height: 80px;
  border-radius: 6px;
  background: linear-gradient(160deg, #ffffff, #f3f1ea);
  color: #1a1a1a;
  box-shadow: 0 3px 6px rgba(0,0,0,.4);
  cursor: pointer;
  border: 1px solid rgba(0,0,0,.15);
  transition: transform .12s ease;
}
.sol-card:hover { transform: translateY(-2px); }
.sol-card.selected { outline: 2px solid #fbbf24; outline-offset: 1px; box-shadow: 0 3px 10px rgba(251,191,36,.5); }

.sol-corner { position: absolute; display: flex; flex-direction: column; align-items: center; line-height: 1; font-weight: 700; }
.sol-corner.tl { top: 4px; left: 5px; }
.sol-corner.br { bottom: 4px; right: 5px; transform: rotate(180deg); }
.sol-corner-rank { font-size: .68rem; }
.sol-corner-suit { font-size: .6rem; }

.sol-pip-ace { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 1.7rem; }

.sol-pip-grid { position: absolute; inset: 14px 8px; display: flex; justify-content: space-between; }
.sol-pip-col { display: flex; flex-direction: column; justify-content: space-evenly; align-items: center; }
.sol-pip { font-size: .55rem; line-height: 1; }
.sol-pip-mid { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: .6rem; }

.sol-face-badge {
  position: absolute;
  inset: 16px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 700;
  font-family: var(--font-sans);
  border: 1.5px solid #1a1a1a;
  border-radius: 4px;
  background: repeating-linear-gradient(45deg, rgba(0,0,0,.03) 0 4px, transparent 4px 8px);
}

/* Diamond-lattice back instead of a flat gradient — no image, just layered
   repeating gradients, matching the site's "hand-coded, no assets" rule. */
.sol-card.face-down {
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.08) 0 2px, transparent 2px 10px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,.08) 0 2px, transparent 2px 10px),
    linear-gradient(160deg, #4c1d95, #2e1065);
  border: 1px solid rgba(255,255,255,.25);
}
.sol-card.face-down:hover { transform: none; }

/* ---- Pinball (iframe-embedded vendored game — see apps/pinball.js) ---- */
.pin-app { display: flex; flex-direction: column; height: 100%; box-sizing: border-box; background: #000; }
.pin-frame { flex: 1; width: 100%; border: none; }
.pin-credit { margin: 0; padding: .35rem .6rem; font-size: .66rem; text-align: center; color: var(--text-muted); background: var(--glass-bg); border-top: 1px solid var(--glass-border); }
.pin-credit a { color: var(--accent); }

/* ---- Snap preview overlay ---- */
.nw-snap-preview {
  position: absolute;
  pointer-events: none;
  z-index: 9998;
  background: var(--accent-dim);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  transition: left .12s ease, top .12s ease, width .12s ease, height .12s ease;
}

[data-theme^="retro"] .nw-snap-preview {
  border-radius: 0;
  border-style: dashed;
}

/* ---- Settings app ---- */
.settings-app {
  padding: 1rem 1.1rem;
  font-size: .85rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.settings-group h3 {
  margin: 0 0 .5rem;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  font-weight: 600;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .45rem 0;
  border-bottom: 1px solid var(--glass-border);
}

.settings-row:last-child { border-bottom: none; }

.settings-row label {
  color: var(--text-secondary);
  flex: 1;
}

.settings-btn {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: .3rem .7rem;
  font-size: .76rem;
  cursor: pointer;
  font-family: var(--font-sans);
}

.settings-btn:hover { background: var(--accent); color: #fff; }

.settings-btn.danger {
  background: rgba(248, 113, 113, .12);
  border-color: var(--danger);
  color: var(--danger);
}

.settings-btn.danger:hover { background: var(--danger); color: #fff; }

.settings-note {
  font-size: .72rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.settings-stat {
  font-family: var(--font-mono);
  color: var(--text-primary);
  font-size: .78rem;
}

/* ---- NightOS taskbar theme controls ---- */
.nightos-theme,
.nightos-retro,
.nightos-retro-variant {
  background: none;
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: .85rem;
  flex-shrink: 0;
}

.nightos-theme:hover,
.nightos-retro:hover,
.nightos-retro-variant:hover {
  color: var(--text-primary);
  border-color: var(--accent);
}

/* Same reasoning as the dashboard topbar's per-button tints (css/main.css):
   these three sit right next to each other as identical grey circles
   otherwise, differing only by a small glyph. */
html:not([data-theme^="retro"]) .nightos-theme         { background: rgba(245,158,11,.16); border-color: rgba(245,158,11,.4); }
html:not([data-theme^="retro"]) .nightos-retro          { background: rgba(217,70,239,.16); border-color: rgba(217,70,239,.4); }
html:not([data-theme^="retro"]) .nightos-retro-variant  { background: rgba(99,102,241,.16); border-color: rgba(99,102,241,.4); }
html:not([data-theme^="retro"]) .nightos-dnd:not(.active) { background: rgba(249,115,22,.14); border-color: rgba(249,115,22,.35); }

.nightos-retro.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}

[data-theme^="retro"] .nightos-theme,
[data-theme^="retro"] .nightos-retro,
[data-theme^="retro"] .nightos-retro-variant {
  border-radius: 0;
  border: 2px solid;
  border-color: var(--bevel-light) var(--bevel-dark) var(--bevel-dark) var(--bevel-light);
  background: var(--btn-bg);
}

[data-theme^="retro"] .nightos-retro.active {
  border-color: var(--bevel-dark) var(--bevel-light) var(--bevel-light) var(--bevel-dark);
}

/* ---- Server Pet app ---- */
.pet-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  padding: 1rem;
  height: 100%;
  box-sizing: border-box;
}

.pet-face {
  font-family: var(--font-ascii, var(--font-mono));
  font-size: 0.72rem;
  line-height: 1.25;
  color: var(--accent);
  margin: 0;
  text-align: center;
  white-space: pre;
  text-shadow: 0 0 12px var(--accent-glow);
}

.pet-name-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pet-name {
  background: transparent;
  border: 1px solid transparent;
  border-bottom-color: var(--glass-border);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  text-align: center;
  padding: 0.2rem 0.4rem;
  width: 8.5rem;
  border-radius: var(--radius-sm);
}

.pet-name:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--accent-dim);
}

.pet-mood {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

.pet-stage {
  font-size: 0.68rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: -0.3rem 0 0.6rem;
}

.pet-stats {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.pet-stat {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.pet-stat label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  width: 5.5rem;
  flex-shrink: 0;
}

.pet-bar {
  flex: 1;
  height: 9px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
}

.pet-bar-fill {
  height: 100%;
  background: var(--success);
  border-radius: 99px;
  transition: width 0.35s ease, background 0.35s ease;
}

.pet-bar-fill.mid { background: var(--warning); }
.pet-bar-fill.low { background: var(--danger); }

.pet-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  justify-content: center;
}

.pet-btn {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.8rem;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: var(--font-sans);
}

.pet-btn:hover { background: var(--accent); color: #fff; }
.pet-btn:active { transform: translateY(1px); }

.pet-log {
  font-size: 0.76rem;
  color: var(--text-secondary);
  text-align: center;
  min-height: 2.2em;
  line-height: 1.4;
  padding: 0 0.5rem;
}

.pet-age {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: auto;
}

/* Retro themes: hard edges, no glow */
[data-theme^="retro"] .pet-face { text-shadow: none; }

[data-theme^="retro"] .pet-bar,
[data-theme^="retro"] .pet-bar-fill,
[data-theme^="retro"] .pet-btn,
[data-theme^="retro"] .pet-name {
  border-radius: 0;
}

[data-theme^="retro"] .pet-bar {
  border: 2px solid;
  border-color: var(--bevel-dark) var(--bevel-light) var(--bevel-light) var(--bevel-dark);
}

[data-theme^="retro"] .pet-btn {
  border: 2px solid;
  border-color: var(--bevel-light) var(--bevel-dark) var(--bevel-dark) var(--bevel-light);
  background: var(--btn-bg);
}

/* ---- Chat app ---- */
.chat-app { height: 100%; display: flex; flex-direction: column; font-size: 0.85rem; }
.chat-app .hidden { display: none !important; }

.chat-gate { padding: 1rem 1.1rem; overflow-y: auto; }
.chat-gate h3 { margin: 0 0 0.7rem; font-size: 1rem; }

.chat-disclaimer p { margin: 0 0 0.6rem; line-height: 1.5; color: var(--text-secondary); }
.chat-disclaimer ul {
  margin: 0 0 0.8rem; padding-left: 1.1rem;
  color: var(--text-secondary); font-size: 0.78rem; line-height: 1.7;
}
.chat-rules { font-size: 0.78rem; }
.chat-warning {
  font-size: 0.78rem; color: var(--warning);
  border-left: 2px solid var(--warning); padding-left: 0.6rem;
}

.chat-join {
  width: 100%; margin-top: 0.6rem; padding: 0.65rem;
  background: var(--accent-dim); border: 1px solid var(--accent);
  color: var(--accent); border-radius: var(--radius-sm);
  font-size: 0.85rem; cursor: pointer; font-family: var(--font-sans);
}
.chat-join:hover { background: var(--accent); color: #fff; }

.chat-room { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.chat-status {
  padding: 0.4rem 0.75rem; font-size: 0.72rem;
  color: var(--text-muted); border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}
.chat-status.muted { color: var(--danger); }
.chat-status.off { color: var(--warning); }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 0.6rem 0.75rem;
  display: flex; flex-direction: column; gap: 0.4rem; min-height: 0;
}

.chat-msg { line-height: 1.45; word-break: break-word; }
.chat-who { color: var(--accent); font-weight: 600; margin-right: 0.4rem; font-size: 0.78rem; }
.chat-text { color: var(--text-primary); }
.chat-time { color: var(--text-muted); font-size: 0.66rem; margin-left: 0.4rem; font-family: var(--font-mono); }

.chat-notice {
  font-size: 0.72rem; color: var(--text-muted);
  font-style: italic; text-align: center; padding: 0.2rem 0;
}

.chat-composer {
  display: flex; gap: 0.4rem; padding: 0.6rem 0.75rem;
  border-top: 1px solid var(--glass-border); flex-shrink: 0;
}

.chat-input {
  flex: 1; background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border); border-radius: var(--radius-sm);
  color: var(--text-primary); padding: 0.5rem 0.6rem;
  font-family: var(--font-sans); font-size: 0.82rem; min-width: 0;
}
.chat-input:focus { outline: none; border-color: var(--accent); }
.chat-input:disabled { opacity: 0.5; }

.chat-send {
  background: var(--accent-dim); border: 1px solid var(--accent);
  color: var(--accent); border-radius: var(--radius-sm);
  padding: 0.5rem 0.85rem; cursor: pointer; font-size: 0.8rem;
  font-family: var(--font-sans); flex-shrink: 0;
}
.chat-send:hover:not(:disabled) { background: var(--accent); color: #fff; }
.chat-send:disabled { opacity: 0.45; cursor: not-allowed; }

.chat-foot {
  display: flex; justify-content: space-between;
  padding: 0 0.75rem 0.5rem; font-size: 0.66rem;
  color: var(--text-muted); font-family: var(--font-mono); flex-shrink: 0;
}

[data-theme^="retro"] .chat-input,
[data-theme^="retro"] .chat-send,
[data-theme^="retro"] .chat-join { border-radius: 0; }

/* ---- Terminal app (mounts the real terminal) ---- */
.dterm {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--terminal-bg);
  font-family: var(--font-mono);
}

.dterm-output {
  flex: 1;
  overflow-y: auto;
  padding: 0.7rem 0.8rem;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--terminal-text);
  min-height: 0;
  overflow-wrap: break-word;
}

/* The real terminal's line classes are shared, so output looks identical
   here and on the dashboard rather than being restyled twice. */
.dterm-output .terminal-line { white-space: pre-wrap; }

.dterm-output .terminal-line.banner {
  font-family: var(--font-ascii, var(--font-mono));
  font-size: 0.4rem;
  line-height: 1.15;
  color: var(--accent);
  overflow-x: auto;
}

.dterm-input-line {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.8rem;
  border-top: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.dterm-prompt {
  color: var(--terminal-prompt);
  font-size: 0.82rem;
  flex-shrink: 0;
}

.dterm-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--terminal-text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  caret-color: var(--terminal-prompt);
  min-width: 0;
}

.dterm-input:disabled { opacity: 0.4; }

/* Chat gate: house rules + legal text */
.chat-gate h4 {
  margin: 0.9rem 0 0.4rem;
  font-size: 0.8rem;
  color: var(--text-primary);
}

.chat-house-rules {
  margin: 0 0 0.8rem;
  padding-left: 1.1rem;
  color: var(--text-secondary);
  font-size: 0.76rem;
  line-height: 1.65;
}

.chat-legal {
  font-size: 0.72rem !important;
  color: var(--text-muted) !important;
  line-height: 1.55;
}

.chat-legal a { color: var(--accent); }
