/* Win98 / MS Paint theme */
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --face: #c0c0c0;
  --hl: #ffffff;
  --sh: #808080;
  --dksh: #404040;
  --title1: #000080;
  --title2: #1084d0;
}

html, body { height: 100%; }
body {
  background: #008080;
  font-family: Tahoma, "MS Sans Serif", "Segoe UI", sans-serif;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.window {
  position: relative;
  background: var(--face);
  border: 2px solid;
  border-color: var(--hl) var(--dksh) var(--dksh) var(--hl);
  box-shadow: 1px 1px 0 var(--sh) inset, -1px -1px 0 var(--sh) inset, 4px 4px 12px rgba(0,0,0,.4);
  display: flex;
  flex-direction: column;
  max-width: 100%;
  overflow: hidden;
}
.titlebar { cursor: default; touch-action: none; }
.resize-grip {
  position: absolute;
  right: 1px; bottom: 1px;
  width: 15px; height: 15px;
  cursor: nwse-resize;
  touch-action: none;
  background:
    linear-gradient(135deg,
      transparent 0 5px,  var(--sh) 5px 7px,  var(--hl) 7px 8px,
      transparent 8px 10px, var(--sh) 10px 12px, var(--hl) 12px 13px,
      transparent 13px);
  z-index: 10;
}
.dialog-body { overflow: auto; }
#app { width: min(1060px, 98vw); height: min(720px, 96vh); }

.titlebar {
  background: linear-gradient(90deg, var(--title1), var(--title2));
  color: #fff;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px;
  user-select: none;
}
.titlebar-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titlebar-buttons button {
  width: 18px; height: 16px;
  font-size: 10px; line-height: 1;
  background: var(--face);
  border: 1px solid;
  border-color: var(--hl) var(--dksh) var(--dksh) var(--hl);
  margin-left: 2px;
  cursor: default;
}

.menubar {
  display: flex;
  align-items: center;
  padding: 2px;
  border-bottom: 1px solid var(--sh);
  position: relative;
  z-index: 30;
}
.menu {
  padding: 3px 8px;
  position: relative;
  cursor: default;
  user-select: none;
}
.menu:hover, .menu.open { background: var(--title1); color: #fff; }
.menu-link { color: inherit; text-decoration: none; }
.menu .dropdown {
  display: none;
  position: absolute;
  top: 100%; left: 0;
  min-width: 210px;
  background: var(--face);
  color: #000;
  border: 2px solid;
  border-color: var(--hl) var(--dksh) var(--dksh) var(--hl);
  box-shadow: 2px 2px 6px rgba(0,0,0,.35);
  padding: 2px;
}
.menu.open .dropdown { display: block; }
.dropdown button {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  text-align: left;
  padding: 4px 18px;
  background: none;
  border: none;
  font: inherit;
  cursor: default;
}
.dropdown button:hover { background: var(--title1); color: #fff; }
.dropdown hr { border: none; border-top: 1px solid var(--sh); border-bottom: 1px solid var(--hl); margin: 3px 2px; }
.shortcut { color: var(--sh); }
.dropdown button:hover .shortcut { color: #cfcfcf; }
.menubar-spacer { flex: 1; }

.userchip { display: flex; align-items: center; gap: 6px; padding-right: 4px; }
.userchip img { width: 20px; height: 20px; border: 1px solid var(--sh); }
.userchip button {
  font: inherit;
  padding: 2px 8px;
  background: var(--face);
  border: 2px solid;
  border-color: var(--hl) var(--dksh) var(--dksh) var(--hl);
  cursor: pointer;
}
.userchip button:active { border-color: var(--dksh) var(--hl) var(--hl) var(--dksh); }

.main { display: flex; flex: 1; min-height: 0; }

.tools {
  width: 64px;
  padding: 4px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  align-content: start;
  border-right: 2px groove var(--hl);
}
.tool {
  height: 26px;
  font-size: 13px;
  background: var(--face);
  border: 2px solid;
  border-color: var(--hl) var(--dksh) var(--dksh) var(--hl);
  cursor: pointer;
}
.tool.active { border-color: var(--dksh) var(--hl) var(--hl) var(--dksh); background: #dcdcdc; }
.tool-options { grid-column: 1 / -1; margin-top: 8px; display: flex; flex-direction: column; gap: 3px; }
.tool-options select { font: inherit; }

.canvas-area {
  flex: 1;
  overflow: auto;
  background: #7b7b7b;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.canvas-stack { position: relative; background: #fff; box-shadow: 3px 3px 0 rgba(0,0,0,.35); cursor: none; }
.canvas-stack canvas {
  display: block;
  image-rendering: pixelated;
  width: calc(var(--cw, 296) * var(--zoom, 3) * 1px);
  height: calc(var(--ch, 152) * var(--zoom, 3) * 1px);
}
#overlay { position: absolute; inset: 0; pointer-events: none; }

.palette {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-top: 2px groove var(--hl);
}
.swatch-current {
  width: 28px; height: 28px;
  background: #000;
  border: 2px solid;
  border-color: var(--dksh) var(--hl) var(--hl) var(--dksh);
}
.swatch {
  width: 22px; height: 22px;
  border: 1px solid var(--dksh);
  cursor: pointer;
}
.swatch.black { background: #000; }
.swatch.white { background: #fff; }
.swatch.active { outline: 2px solid var(--title1); outline-offset: 1px; }
.dither-label { display: flex; align-items: center; gap: 4px; margin-left: 10px; }
.palette-spacer { flex: 1; }
.send-btn {
  font: inherit;
  font-weight: bold;
  padding: 5px 14px;
  background: var(--face);
  border: 2px solid;
  border-color: var(--hl) var(--dksh) var(--dksh) var(--hl);
  cursor: pointer;
}
.send-btn:active { border-color: var(--dksh) var(--hl) var(--hl) var(--dksh); }
.send-btn:disabled { color: var(--sh); text-shadow: 1px 1px 0 var(--hl); }

.statusbar {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-top: 1px solid var(--hl);
}
.statusbar > span {
  border: 1px solid;
  border-color: var(--sh) var(--hl) var(--hl) var(--sh);
  padding: 2px 8px;
}
#statusMsg { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-cell { min-width: 110px; }

/* retro blocks progress bar */
.progress98 {
  width: 170px;
  padding: 2px !important;
  background: #fff;
  display: flex;
  align-items: stretch;
}
#progressBar {
  display: block;
  width: 0%;
  background: repeating-linear-gradient(90deg,
    var(--title1) 0 9px, transparent 9px 12px);
  transition: width .3s steps(4);
}

/* dialogs */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.25);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.dialog { width: 340px; }
.dialog.wide { width: min(720px, 94vw); }
.dialog-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.dialog-body textarea, .dialog-body input[type=text] {
  font: inherit; width: 100%; padding: 4px;
  border: 2px solid; border-color: var(--sh) var(--hl) var(--hl) var(--sh);
  background: #fff;
}
.dialog-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dialog-row select, .dialog-row input[type=number] { font: inherit; padding: 2px; }
.dialog-row input[type=number] { width: 60px; }
.dialog-row.buttons { justify-content: flex-end; }
.dialog-row.buttons button, .about button {
  font: inherit; min-width: 72px; padding: 4px 12px;
  background: var(--face);
  border: 2px solid; border-color: var(--hl) var(--dksh) var(--dksh) var(--hl);
  cursor: pointer;
}
.dialog-row.buttons button:active { border-color: var(--dksh) var(--hl) var(--hl) var(--dksh); }
.btn-default { outline: 1px solid #000; }
.preview-row { background: #fff; border: 1px solid var(--sh); justify-content: center; }
.about { line-height: 1.5; }
.about ol { padding-left: 20px; }
.about a { color: var(--title1); }

/* badge grids (my drawings / explore) */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  max-height: 60vh;
  overflow: auto;
  padding: 4px;
}
.badge-card {
  background: var(--face);
  border: 2px solid;
  border-color: var(--hl) var(--dksh) var(--dksh) var(--hl);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.badge-card canvas {
  width: 100%;
  image-rendering: pixelated;
  background: #fff;
  border: 1px solid var(--sh);
}
.badge-card .meta { display: flex; align-items: center; gap: 6px; }
.badge-card .meta img { width: 18px; height: 18px; border: 1px solid var(--sh); }
.badge-card .meta .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge-card .row { display: flex; gap: 4px; }
.badge-card .row button {
  flex: 1; font: inherit; font-size: 11px; padding: 3px;
  background: var(--face);
  border: 2px solid; border-color: var(--hl) var(--dksh) var(--dksh) var(--hl);
  cursor: pointer;
}
.badge-card .title { font-weight: bold; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dialog-signin { margin-top: 2px; }
.dialog-signin hr { border: none; border-top: 1px solid var(--sh); border-bottom: 1px solid var(--hl); margin: 6px 0; }
.dialog-signin p { line-height: 1.5; margin-bottom: 8px; }
button:disabled { color: var(--sh); text-shadow: 1px 1px 0 var(--hl); cursor: default; }

/* desktop landing */
body.desktop {
  display: block;
  padding: 0;
  overflow: hidden;
}
body.dragging iframe { pointer-events: none; }

/* app windows (iframe shells) */
.app-window { min-width: 320px; min-height: 220px; }
.app-window iframe {
  flex: 1;
  width: 100%;
  border: none;
  background: var(--face);
}
.app-window.maximized {
  left: 0 !important;
  top: 0 !important;
  width: 100vw !important;
  height: calc(100vh - 36px) !important;
}
.titlebar-icon-img { width: 16px; height: 16px; image-rendering: pixelated; }
.px-icon { width: 16px; height: 16px; image-rendering: pixelated; vertical-align: -3px; }
.biglogo-img { width: 64px; height: 64px; image-rendering: pixelated; }
.tool .px-icon { vertical-align: middle; }
.task-buttons { display: flex; gap: 4px; flex: 1; overflow: hidden; }
.task-btn {
  font: inherit;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 140px;
  max-width: 200px;
  padding: 3px 8px;
  background: var(--face);
  border: 2px solid;
  border-color: var(--hl) var(--dksh) var(--dksh) var(--hl);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
}
.task-btn img { width: 16px; height: 16px; image-rendering: pixelated; }
.task-btn.active {
  border-color: var(--dksh) var(--hl) var(--hl) var(--dksh);
  background: #dcdcdc;
  font-weight: bold;
}

/* embedded mode: page runs inside a shell app-window, hide own chrome */
.embedded body { padding: 0; background: var(--face); display: block; }
.embedded #app, .embedded #explorePage {
  width: 100% !important;
  height: 100vh !important;
  max-width: none;
  border: none;
  box-shadow: none;
}
.embedded #app > .titlebar, .embedded #explorePage > .titlebar { display: none; }
.embedded #app > .resize-grip, .embedded #explorePage > .resize-grip { display: none; }
.desktop-icons {
  position: absolute;
  top: 18px; left: 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  z-index: 1;
}
.desktop-icon {
  width: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  text-decoration: none;
  color: #fff;
}
button.desktop-icon {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  font: inherit;
  color: #fff;
  cursor: pointer;
}
.desktop-icon img {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  filter: drop-shadow(2px 2px 0 rgba(0,0,0,.5));
}
.desktop-icon .icon-img {
  font-size: 40px;
  line-height: 1;
  filter: drop-shadow(2px 2px 0 rgba(0,0,0,.5));
}
.desktop-icon .icon-label {
  font-size: 12px;
  text-align: center;
  padding: 1px 4px;
  text-shadow: 1px 1px 0 #000;
}
.desktop-icon:hover .icon-label, .desktop-icon:focus .icon-label {
  background: var(--title1);
  outline: 1px dotted #fff;
}
.login-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-window { width: 380px; }
.login-body { padding: 18px; display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center; }
.login-body .biglogo { font-size: 44px; }
.login-body h1 { font-size: 16px; }
.login-body p { line-height: 1.5; color: #222; }
.login-body .userline { display: flex; align-items: center; gap: 8px; }
.login-body .userline img { width: 28px; height: 28px; border: 1px solid var(--sh); }
.btn98 {
  font: inherit;
  padding: 6px 16px;
  min-width: 180px;
  background: var(--face);
  border: 2px solid;
  border-color: var(--hl) var(--dksh) var(--dksh) var(--hl);
  cursor: pointer;
}
.btn98:active { border-color: var(--dksh) var(--hl) var(--hl) var(--dksh); }
.btn98.primary { font-weight: bold; outline: 1px solid #000; }
.guest-link { color: var(--title1); font-size: 11px; }
.taskbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 34px;
  background: var(--face);
  border-top: 2px solid var(--hl);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 6px;
  z-index: 5;
}
.start-btn {
  font: inherit;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  background: var(--face);
  border: 2px solid;
  border-color: var(--hl) var(--dksh) var(--dksh) var(--hl);
  cursor: pointer;
}
.taskbar .clock {
  margin-left: auto;
  border: 1px solid;
  border-color: var(--sh) var(--hl) var(--hl) var(--sh);
  padding: 3px 12px;
}

/* explore page */
#explorePage { width: min(1100px, 98vw); height: min(760px, 96vh); }
#explorePage .explore-body { flex: 1; overflow: auto; padding: 14px; }
#explorePage .badge-grid { max-height: none; }
.explore-toolbar { display: flex; gap: 8px; align-items: center; padding: 6px 14px; border-bottom: 1px solid var(--sh); }
.explore-toolbar a { color: var(--title1); }
