/* ============================================================
   Windows, Taskbar, Start Menu — XP/2000 chrome
   ============================================================ */

/* ----- Window ----- */
.win {
  position: absolute;
  background: var(--chrome-face);
  box-shadow:
    0 0 0 1px #0a2a7a,
    3px 3px 0 rgba(0,0,0,0.18),
    0 20px 50px -12px rgba(0,0,0,0.45);
  border-radius: 8px 8px 2px 2px;
  overflow: hidden;
  min-width: 240px;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.win.inactive { filter: saturate(0.8) brightness(0.98); }
.win.inactive .titlebar { background: linear-gradient(180deg, var(--tb-inactive-a), var(--tb-inactive-b)); }
.win.minimized { display: none; }

.titlebar {
  flex: 0 0 auto;
  height: 28px;
  background: linear-gradient(180deg, var(--tb-a) 0%, var(--tb-b) 45%, var(--tb-a) 55%, var(--tb-c) 100%);
  color: var(--chrome-text);
  display: flex;
  align-items: center;
  padding: 0 4px 0 6px;
  font-family: var(--ff-title);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.2px;
  cursor: grab;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.5);
  gap: 6px;
  user-select: none;
}
.titlebar:active { cursor: grabbing; }
.titlebar .tb-ico {
  width: 16px; height: 16px;
  filter: drop-shadow(1px 1px 0 rgba(0,0,0,0.4));
}
.titlebar .tb-title {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.titlebar .tb-controls {
  display: flex;
  gap: 2px;
}
.tb-btn {
  width: 22px; height: 22px;
  border: 1px solid rgba(0,0,0,0.3);
  background: linear-gradient(180deg, #fff 0%, #dde5f2 50%, #c7d2e8 100%);
  border-radius: 3px;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-weight: 700;
  color: #0a246a;
  box-shadow: inset 1px 1px 0 rgba(255,255,255,0.6);
  padding: 0;
}
.tb-btn:hover { background: linear-gradient(180deg, #fff 0%, #ffecd1 60%, #ffb366 100%); color: #5a1a00; }
.tb-btn.close:hover { background: linear-gradient(180deg, #ff9d85 0%, #e23c1a 100%); color: #fff; }
.tb-btn svg { width: 10px; height: 10px; }
.tb-btn.max svg { width: 12px; height: 12px; }

/* Maximized state: no rounding, no shadow to bleed outside viewport */
.win.maximized-state {
  box-shadow: none !important;
  border-radius: 0 !important;
}

.win-body {
  flex: 1;
  background: var(--win-body);
  color: var(--win-text);
  padding: 10px 12px;
  overflow: auto;
  border-top: 1px solid var(--win-hl);
  position: relative;
}
.win-body::-webkit-scrollbar { width: 16px; height: 16px; }
.win-body::-webkit-scrollbar-track {
  background:
    repeating-linear-gradient(45deg, #d6d2bd 0 2px, #e8e4d0 2px 4px);
}
.win-body::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #fff 0%, #d0d0bb 100%);
  border: 1px solid #808070;
}
.win-body::-webkit-scrollbar-button {
  background: linear-gradient(180deg, #fff 0%, #d0d0bb 100%);
  border: 1px solid #808070;
  height: 16px; width: 16px;
}

/* Dark theme scrollbar */
[data-theme="crt"] .win-body::-webkit-scrollbar-track {
  background: repeating-linear-gradient(45deg, #0a130d 0 2px, #0f1a13 2px 4px);
}
[data-theme="crt"] .win-body::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #1e3a24 0%, #0a130d 100%);
  border: 1px solid #2a4d32;
}

.win-body h1, .win-body h2, .win-body h3 {
  font-family: var(--ff-title);
  margin: 0 0 8px;
  color: var(--win-text);
}
.win-body h1 { font-size: 22px; }
.win-body h2 { font-size: 16px; }
.win-body p  { line-height: 1.5; margin: 0 0 8px; font-size: 12.5px; }
.win-body a  { color: #0050c8; }
[data-theme="crt"] .win-body a { color: #8fff8f; }

.win-statusbar {
  flex: 0 0 auto;
  height: 22px;
  background: var(--chrome-face);
  border-top: 1px solid var(--win-hl);
  display: flex;
  align-items: center;
  padding: 0 6px;
  font-size: 11px;
  color: #444;
  gap: 10px;
  box-shadow: inset 1px 1px 0 rgba(0,0,0,0.08);
}
.win-statusbar .cell {
  border: 1px inset #b0ab95;
  padding: 1px 8px;
  background: #d9d5be;
}
[data-theme="crt"] .win-statusbar { color: #6cff6c; }
[data-theme="crt"] .win-statusbar .cell { background: #0a130d; border-color: #1e3a24; }

/* Generic panel styles inside windows */
.panel {
  background: var(--win-sunken-bg);
  border: 1px solid var(--win-line);
  box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 #dcd7b8;
  padding: 10px;
}
[data-theme="crt"] .panel {
  box-shadow: inset 1px 1px 0 #1a2d1f, inset -1px -1px 0 #050a06;
}

.btn {
  display: inline-block;
  padding: 4px 12px;
  background: linear-gradient(180deg, #fff 0%, #dbd9c6 100%);
  border: 1px solid #808070;
  border-radius: 3px;
  box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 #9a9780;
  cursor: pointer;
  font-size: 12px;
  color: var(--win-text);
  text-decoration: none;
}
.btn:hover { background: linear-gradient(180deg, #fff 0%, #ffe5bb 100%); }
.btn:active { box-shadow: inset 2px 2px 0 #9a9780; transform: translate(1px,1px); }
.btn.primary {
  background: linear-gradient(180deg, #6cb6ff 0%, #1a6bc0 100%);
  color: #fff;
  border-color: #0a3a7a;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}
.btn.primary:hover {
  background: linear-gradient(180deg, #8bcbff 0%, #2a7bd0 100%);
}
[data-theme="crt"] .btn {
  background: linear-gradient(180deg, #1a2d1f, #0a130d);
  color: #6cff6c;
  border-color: #2a4d32;
  box-shadow: inset 1px 1px 0 #2a4d32, inset -1px -1px 0 #050a06;
}

/* ============================================================
   Taskbar
   ============================================================ */
#taskbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 36px;
  background: linear-gradient(180deg, var(--taskbar-b) 0%, var(--taskbar-a) 12%, var(--taskbar-a) 88%, var(--taskbar-c) 100%);
  display: flex;
  align-items: center;
  padding: 0 0 0 0;
  z-index: 9000;
  box-shadow: 0 -1px 0 rgba(255,255,255,0.25) inset, 0 -3px 8px rgba(0,0,0,0.25);
  color: #fff;
  font-family: var(--ff-title);
  font-weight: 700;
  user-select: none;
}

#start-btn {
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px 0 10px;
  background: linear-gradient(180deg, var(--start-b) 0%, var(--start-a) 50%, var(--start-c) 100%);
  color: var(--start-text);
  border: none;
  border-top-right-radius: 14px;
  border-bottom-right-radius: 14px;
  font-size: 15px;
  font-style: italic;
  font-weight: 700;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.45);
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.5),
    inset 0 -6px 12px rgba(0,0,0,0.12);
  letter-spacing: 0.3px;
}
#start-btn:hover { filter: brightness(1.1); }
#start-btn[aria-expanded="true"] { filter: brightness(0.9); }
#start-btn .start-ico { width: 20px; height: 20px; flex: 0 0 20px; }

#taskbar-apps {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 6px;
  overflow: hidden;
}
.task-app {
  height: 28px;
  padding: 0 10px 0 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(180deg, var(--tb-b), var(--tb-a));
  color: #fff;
  border: 1px solid rgba(0,0,0,0.35);
  box-shadow: inset 1px 1px 0 rgba(255,255,255,0.25);
  border-radius: 3px;
  font-size: 12px;
  cursor: pointer;
  max-width: 180px;
  min-width: 80px;
}
.task-app .tapp-ico { width: 16px; height: 16px; flex: 0 0 16px; }
.task-app .tapp-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-app.active {
  background: linear-gradient(180deg, var(--tb-c), var(--tb-a));
  box-shadow: inset 2px 2px 2px rgba(0,0,0,0.3);
}

#sys-tray {
  height: 34px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 0 14px;
  background: linear-gradient(180deg, #1a56cc 0%, #0a3f99 100%);
  border-left: 1px solid rgba(255,255,255,0.2);
  box-shadow: inset 1px 0 0 rgba(0,0,0,0.2);
  font-size: 12px;
}
#sys-tray .tray-ico {
  width: 16px; height: 16px;
  cursor: pointer;
  opacity: 0.95;
}
#sys-tray .tray-ico:hover { opacity: 1; filter: brightness(1.2); }
#sys-tray .tray-clock {
  text-align: right;
  line-height: 1.1;
  min-width: 54px;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.45);
  cursor: default;
}
#sys-tray .tray-clock small { font-size: 10px; font-weight: 400; opacity: 0.85; display: block; }
#sys-tray .tray-flag {
  border: 1px solid rgba(255,255,255,0.5);
  padding: 1px 5px;
  font-size: 10px;
  border-radius: 2px;
  cursor: pointer;
}

/* ============================================================
   Start menu
   ============================================================ */
#start-menu {
  position: fixed;
  bottom: 36px;
  left: 0;
  width: 340px;
  background: linear-gradient(180deg, #f1f5fd, #d5e0f2);
  border: 2px solid var(--taskbar-a);
  border-bottom: none;
  border-top-right-radius: 8px;
  box-shadow: 4px 0 12px rgba(0,0,0,0.4), 0 -4px 12px rgba(0,0,0,0.2);
  z-index: 8999;
  display: none;
  overflow: hidden;
  font-family: var(--ff-ui);
  color: #222;
}
#start-menu.open { display: block; }

.start-header {
  background: linear-gradient(180deg, #2f71d6 0%, var(--taskbar-a) 100%);
  padding: 10px 12px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 2px solid #f9a900;
}
.start-header .avatar {
  width: 42px; height: 42px;
  background: #d44; border: 2px solid #fff;
  border-radius: 4px;
  display: grid; place-items: center;
  font-family: var(--ff-title);
  font-size: 18px;
  color: #fff;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
  box-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}
.start-header .who {
  font-size: 14px;
  font-weight: 700;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.5);
}
.start-header .who small { display: block; font-weight: 400; font-size: 10.5px; opacity: 0.85; }

.start-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background:
    linear-gradient(180deg, #ffffff, #f3f3f3);
}
.start-col {
  padding: 6px 4px;
}
.start-col.right {
  background: linear-gradient(180deg, #d3dff2, #c1d1ea);
  border-left: 1px solid #aabada;
}

.start-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  color: #111;
}
.start-item:hover { background: linear-gradient(180deg, #316ac5, #1851bc); color: #fff; }
.start-item .si-ico { width: 22px; height: 22px; flex: 0 0 22px; }
.start-item b { display: block; font-size: 12.5px; }
.start-item small { color: #555; font-size: 11px; }
.start-item:hover small { color: #dbe7ff; }

.start-sep { height: 1px; background: #c0c0c0; margin: 4px 8px; }

.start-footer {
  background: linear-gradient(180deg, #2f71d6 0%, var(--taskbar-a) 100%);
  padding: 6px 8px;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  color: #fff;
}
.start-footer .start-item {
  background: rgba(255,255,255,0.05);
  color: #fff;
}
.start-footer .start-item:hover { background: rgba(255,255,255,0.2); }

/* ============================================================
   Tweaks floating panel
   ============================================================ */
#tweaks-panel {
  position: fixed;
  right: 14px;
  bottom: 50px;
  width: 220px;
  background: var(--chrome-face);
  border: 1px solid #0a2a7a;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.2), 0 10px 30px rgba(0,0,0,0.3);
  z-index: 9500;
  font-family: var(--ff-ui);
  font-size: 12px;
  display: none;
}
#tweaks-panel.open { display: block; }
#tweaks-panel .tweaks-title {
  background: linear-gradient(180deg, var(--tb-a), var(--tb-c));
  color: #fff;
  font-family: var(--ff-title);
  font-weight: 700;
  padding: 4px 4px 4px 8px;
  font-size: 12px;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#tweaks-panel .tweaks-close {
  width: 18px; height: 18px;
  background: linear-gradient(180deg, #fff 0%, #dde5f2 50%, #c7d2e8 100%);
  border: 1px solid rgba(0,0,0,0.3);
  border-radius: 3px;
  color: #0a246a;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: inset 1px 1px 0 rgba(255,255,255,0.6);
  padding: 0;
  flex-shrink: 0;
}
#tweaks-panel .tweaks-close:hover {
  background: linear-gradient(180deg, #ff9d85 0%, #e23c1a 100%);
  color: #fff;
}
#tweaks-panel .tweaks-body { padding: 10px; }
#tweaks-panel label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  cursor: pointer;
}
#tweaks-panel .theme-row {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}
#tweaks-panel .theme-row button {
  flex: 1;
  padding: 4px;
  font-size: 11px;
  background: linear-gradient(180deg, #fff, #d8d4bb);
  border: 1px solid #808070;
  cursor: pointer;
  border-radius: 2px;
}
#tweaks-panel .theme-row button.active {
  background: linear-gradient(180deg, #ffd07a, #d4831a);
  color: #fff;
  font-weight: 700;
}
[data-theme="crt"] #tweaks-panel {
  background: #0f1a13;
  color: #6cff6c;
  border-color: #2a4d32;
}

/* ============================================================
   Mobile: taskbar + start menu
   ============================================================ */
@media (max-width: 600px) {
  #start-btn .start-label { display: none; }
  #start-btn { padding: 0 10px; }
  #sys-tray { padding: 0 6px 0 8px; gap: 6px; }
  #sys-tray .tray-clock small { display: none; }
  .task-app { min-width: 50px; max-width: 110px; }
  #start-menu { width: min(340px, 100vw); }
}
