/* Windows 3.x look: flat VGA colours, 1-pixel black lines, bevelled grey buttons. */
:root {
  --black: #000000; --white: #ffffff; --silver: #c0c0c0; --gray: #808080;
  --navy: #000080; --blue: #0000ff; --teal: #008080; --cyan: #00ffff;
  --red: #ff0000; --yellow: #ffff00; --magenta: #ff00ff;
  --desktop: #008080;
  --font: bold 13px/16px Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--desktop);
  font: var(--font);
  color: var(--black);
  user-select: none;
  -webkit-user-select: none;
  -webkit-font-smoothing: none;
  font-smooth: never;
}
body.busy, body.busy * { cursor: var(--cur-wait), wait !important; }
body { cursor: var(--cur-arrow), default; }

#desktop { position: absolute; inset: 0; overflow: hidden; background-color: var(--desktop); }

/* ------------------------------------------------------------ windows */
.win {
  position: absolute;
  background: var(--silver);
  border: 1px solid var(--black);
  padding: 3px;
  display: flex;
  flex-direction: column;
}
/* corner notches in the sizing border */
.win.sizable::before, .win.sizable::after {
  content: ''; position: absolute; pointer-events: none;
  inset: -1px;
  background:
    linear-gradient(var(--black), var(--black)) left 22px top 0 / 1px 4px no-repeat,
    linear-gradient(var(--black), var(--black)) right 22px top 0 / 1px 4px no-repeat,
    linear-gradient(var(--black), var(--black)) left 22px bottom 0 / 1px 4px no-repeat,
    linear-gradient(var(--black), var(--black)) right 22px bottom 0 / 1px 4px no-repeat,
    linear-gradient(var(--black), var(--black)) left 0 top 22px / 4px 1px no-repeat,
    linear-gradient(var(--black), var(--black)) right 0 top 22px / 4px 1px no-repeat,
    linear-gradient(var(--black), var(--black)) left 0 bottom 22px / 4px 1px no-repeat,
    linear-gradient(var(--black), var(--black)) right 0 bottom 22px / 4px 1px no-repeat;
}
.win.maximized { border-width: 0; padding: 0; }
.win.maximized::before, .win.maximized::after { display: none; }
.win.dialog { padding: 4px; border: 1px solid var(--black); background: var(--navy); }
.win.dialog.inactive { background: var(--white); }
.win-inner {
  border: 1px solid var(--black);
  background: var(--white);
  display: flex; flex-direction: column;
  flex: 1; min-height: 0;
}

.titlebar {
  height: 20px; flex: none;
  display: flex; align-items: stretch;
  background: var(--navy);
  color: var(--white);
  border-bottom: 1px solid var(--black);
}
.win.inactive .titlebar { background: var(--white); color: var(--black); }
.titlebar .title {
  flex: 1; text-align: center; line-height: 19px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px;
}
.sysbox {
  width: 20px; flex: none; background: var(--silver);
  border-right: 1px solid var(--black);
  position: relative;
}
.sysbox::after {
  content: ''; position: absolute; left: 4px; top: 8px; width: 11px; height: 3px;
  background: var(--white); border: 1px solid var(--black); box-shadow: 1px 1px 0 var(--gray);
}
.sysbox.open { background: var(--black); }
.tbtn {
  width: 20px; flex: none; background: var(--silver);
  border-left: 1px solid var(--black);
  box-shadow: inset 1px 1px 0 var(--white), inset -1px -1px 0 var(--gray), inset -2px -2px 0 var(--gray);
  display: flex; align-items: center; justify-content: center;
}
.tbtn:active, .tbtn.pressed { box-shadow: inset 1px 1px 0 var(--gray); padding: 1px 0 0 1px; }
.tri-down, .tri-up { width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; }
.tri-down { border-top: 4px solid var(--black); }
.tri-up { border-bottom: 4px solid var(--black); }
.tbtn.restore { flex-direction: column; gap: 1px; }

/* ------------------------------------------------------------ menus */
.menubar {
  height: 20px; flex: none; display: flex;
  background: var(--white);
  border-bottom: 1px solid var(--black);
  padding-left: 2px;
}
.menubar .mtitle { padding: 2px 7px 0; line-height: 16px; white-space: nowrap; }
.menubar .mtitle.open { background: var(--navy); color: var(--white); }
u { text-decoration: underline; text-underline-offset: 1px; }

.menu {
  position: fixed; z-index: 10000;
  background: var(--white);
  border: 1px solid var(--black);
  box-shadow: 2px 2px 0 var(--black);
  padding: 1px 0;
  min-width: 150px;
}
.menu .mi {
  display: flex; align-items: center;
  padding: 1px 16px 1px 0; line-height: 16px; white-space: nowrap;
}
.menu .mi .chk { width: 18px; flex: none; text-align: center; }
.menu .mi .lbl { flex: 1; padding-right: 22px; }
.menu .mi .acc { flex: none; }
.menu .mi .sub { flex: none; margin-left: 6px; width: 0; height: 0; border-top: 4px solid transparent; border-bottom: 4px solid transparent; border-left: 4px solid currentColor; }
.menu .mi.hot { background: var(--navy); color: var(--white); }
.menu .mi.disabled { color: var(--gray); }
.menu .sep { height: 1px; background: var(--black); margin: 3px 0; }

/* check mark drawn as pixels */
.checkmark { display: inline-block; width: 8px; height: 8px; position: relative; top: 0; }
.checkmark::before {
  content: ''; position: absolute; left: 0; top: 0; width: 8px; height: 8px;
  background:
    linear-gradient(currentColor, currentColor) 7px 0 / 1px 2px no-repeat,
    linear-gradient(currentColor, currentColor) 6px 1px / 1px 2px no-repeat,
    linear-gradient(currentColor, currentColor) 5px 2px / 1px 2px no-repeat,
    linear-gradient(currentColor, currentColor) 4px 3px / 1px 2px no-repeat,
    linear-gradient(currentColor, currentColor) 3px 4px / 1px 3px no-repeat,
    linear-gradient(currentColor, currentColor) 2px 5px / 1px 3px no-repeat,
    linear-gradient(currentColor, currentColor) 1px 4px / 1px 3px no-repeat,
    linear-gradient(currentColor, currentColor) 0 3px / 1px 3px no-repeat;
}
.radiodot { display: inline-block; width: 6px; height: 6px; background: currentColor; }

/* ------------------------------------------------------------ app layout */
.client { flex: 1; display: flex; min-height: 0; background: var(--white); }
#view { flex: 1; position: relative; overflow: hidden; background: var(--black); min-width: 0; }
#view canvas.view3d { position: absolute; left: 0; top: 0; image-rendering: pixelated; image-rendering: crisp-edges; display: block; }
#side {
  width: 196px; flex: none; display: flex; flex-direction: column;
  border-left: 1px solid var(--black); background: var(--white);
  padding: 6px 6px 6px 7px; gap: 6px;
}
#side.hidden { display: none; }
.statusbar {
  height: 22px; flex: none; display: flex; gap: 4px; align-items: center;
  background: var(--silver); border-top: 1px solid var(--black); padding: 0 3px;
}
.statusbar.hidden { display: none; }
.sfield {
  height: 17px; line-height: 15px; padding: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border: 1px solid; border-color: var(--gray) var(--white) var(--white) var(--gray);
  font-weight: normal;
}
.sfield.grow { flex: 1; }

.label { line-height: 16px; }
.turnbox { display: flex; align-items: center; gap: 6px; }
.turnbox .swatch { width: 26px; height: 26px; border: 1px solid var(--black); image-rendering: pixelated; flex: none; background: var(--black); }
.turnbox .txt { line-height: 15px; }
.clocks { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; font-weight: normal; }
.clocks b { font-weight: bold; }
.clocks .run { background: var(--navy); color: var(--white); padding: 0 2px; }

/* ------------------------------------------------------------ list boxes */
.listbox {
  border: 1px solid var(--black); background: var(--white);
  overflow-y: scroll; overflow-x: hidden; font-weight: normal; min-height: 0;
}
.listbox .row { display: flex; line-height: 16px; padding: 0 2px; white-space: nowrap; }
.listbox .row.sel { background: var(--navy); color: var(--white); }
.movelist { flex: 1; }
.movelist .row span { display: inline-block; }
.movelist .n { width: 30px; text-align: right; padding-right: 6px; color: var(--black); }
.movelist .mv { width: 58px; padding: 0 2px; }
.movelist .mv.cur { background: var(--navy); color: var(--white); }

/* scroll bars, Windows 3 style (WebKit/Blink) */
.listbox::-webkit-scrollbar, .scroll::-webkit-scrollbar { width: 17px; height: 17px; }
.listbox::-webkit-scrollbar-track, .scroll::-webkit-scrollbar-track { background: var(--silver); border-left: 1px solid var(--black); }
.listbox::-webkit-scrollbar-thumb, .scroll::-webkit-scrollbar-thumb {
  background: var(--silver); border: 1px solid var(--black);
  box-shadow: inset 1px 1px 0 var(--white), inset -1px -1px 0 var(--gray);
}
.listbox::-webkit-scrollbar-button:single-button, .scroll::-webkit-scrollbar-button:single-button {
  display: block; height: 17px; background-color: var(--silver); border: 1px solid var(--black);
  box-shadow: inset 1px 1px 0 var(--white), inset -1px -1px 0 var(--gray);
  background-repeat: no-repeat; background-position: center;
}
.listbox::-webkit-scrollbar-button:single-button:vertical:decrement, .scroll::-webkit-scrollbar-button:single-button:vertical:decrement {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='7' height='4' shape-rendering='crispEdges'%3E%3Cpath d='M3 0h1v1h1v1h1v1h1v1H0V3h1V2h1V1h1z'/%3E%3C/svg%3E");
}
.listbox::-webkit-scrollbar-button:single-button:vertical:increment, .scroll::-webkit-scrollbar-button:single-button:vertical:increment {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='7' height='4' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h7v1H6v1H5v1H4v1H3V3H2V2H1V1H0z'/%3E%3C/svg%3E");
}
.listbox, .scroll { scrollbar-color: var(--silver) var(--silver); }

/* ------------------------------------------------------------ buttons */
.btn {
  font: var(--font);
  background: var(--silver); color: var(--black);
  border: 1px solid var(--black);
  border-radius: 0;
  box-shadow: inset 1px 1px 0 var(--white), inset 2px 2px 0 var(--white), inset -1px -1px 0 var(--gray), inset -2px -2px 0 var(--gray);
  padding: 3px 10px 4px; min-width: 76px; height: 26px;
  outline: none; position: relative;
  clip-path: polygon(1px 0, calc(100% - 1px) 0, 100% 1px, 100% calc(100% - 1px), calc(100% - 1px) 100%, 1px 100%, 0 calc(100% - 1px), 0 1px);
}
.btn.default { border-width: 2px; }
.btn:active:not(:disabled), .btn.pressed {
  box-shadow: inset 1px 1px 0 var(--gray), inset 2px 2px 0 var(--gray);
  padding: 4px 9px 3px 11px;
}
.btn:disabled { color: var(--gray); }
.btn:focus-visible .cap, .btn.focus .cap { outline: 1px dotted var(--black); outline-offset: 0; }
.btn.small { min-width: 0; height: 24px; padding: 2px 6px 3px; }
.btnrow { display: flex; gap: 6px; flex-wrap: wrap; }
.btnrow .btn { flex: 1; min-width: 0; }

/* ------------------------------------------------------------ dialogs */
.modal-shield { position: fixed; inset: 0; z-index: 5000; }
.dialog .body { padding: 12px 14px 12px; background: var(--white); }
.dialog .msg { display: flex; gap: 14px; align-items: flex-start; }
.dialog .msg .icon { width: 32px; height: 32px; flex: none; image-rendering: pixelated; }
.dialog .msg .text { padding-top: 6px; line-height: 17px; max-width: 360px; white-space: pre-line; }
.dialog .buttons { display: flex; justify-content: center; gap: 10px; margin-top: 16px; }
.dialog .buttons.right { flex-direction: column; justify-content: flex-start; margin-top: 0; }
.groupbox { border: 1px solid var(--black); padding: 10px 10px 8px; position: relative; margin-top: 8px; }
.groupbox > .legend { position: absolute; top: -9px; left: 8px; background: var(--white); padding: 0 3px; }
.ctl { display: flex; align-items: center; gap: 7px; line-height: 20px; }
.ctl input { position: absolute; opacity: 0; pointer-events: none; }
.chkbox {
  width: 13px; height: 13px; border: 1px solid var(--black); background: var(--white); flex: none; position: relative;
}
.chkbox.on::before, .chkbox.on::after {
  content: ''; position: absolute; left: 5px; top: -1px; width: 1px; height: 13px; background: var(--black);
}
.chkbox.on::before { transform: rotate(45deg); }
.chkbox.on::after { transform: rotate(-45deg); }
.radio {
  width: 12px; height: 12px; border: 1px solid var(--black); border-radius: 50%; background: var(--white); flex: none; position: relative;
}
.radio.on::after { content: ''; position: absolute; left: 2px; top: 2px; width: 6px; height: 6px; border-radius: 50%; background: var(--black); }
.ctl.disabled { color: var(--gray); }
.ctl:focus-within .lbltxt { outline: 1px dotted var(--black); }
.textfield {
  font: var(--font); font-weight: normal; border: 1px solid var(--black); background: var(--white);
  height: 22px; padding: 1px 3px; outline: none; border-radius: 0; width: 100%;
}
.textarea { font: 12px/15px "Courier New", Courier, monospace; border: 1px solid var(--black); width: 100%; height: 130px; resize: none; outline: none; padding: 3px; border-radius: 0; }
.cols { display: flex; gap: 12px; }
.cols > * { flex: 1; }
.swatchlist .row { gap: 6px; align-items: center; }
.swatchlist .sw { width: 22px; height: 12px; border: 1px solid var(--black); flex: none; }
.promo-grid { display: grid; grid-template-columns: repeat(4, 64px); gap: 8px; justify-content: center; }
.promo-grid .btn { height: 76px; min-width: 0; padding: 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.promo-grid .btn img { width: 40px; height: 48px; image-rendering: pixelated; }
.patternpreview { width: 96px; height: 64px; border: 1px solid var(--black); image-rendering: pixelated; }

/* ------------------------------------------------------------ desktop icons */
.deskicon {
  position: absolute; width: 76px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--white); text-align: center;
}
.deskicon img { width: 32px; height: 32px; image-rendering: pixelated; }
.deskicon .cap { padding: 0 2px; line-height: 15px; font-weight: bold; }
.deskicon.sel .cap { background: var(--navy); color: var(--white); }

/* ------------------------------------------------------------ help window */
.helpwin .toolbar { display: flex; gap: 3px; padding: 3px; background: var(--silver); border-bottom: 1px solid var(--black); }
.helpwin .toolbar .btn { min-width: 64px; height: 24px; padding: 2px 6px; }
.helpwin .content {
  flex: 1; overflow-y: auto; padding: 8px 12px 16px; background: var(--white);
  font: 14px/19px "Times New Roman", Times, serif; user-select: text; -webkit-user-select: text;
}
.helpwin .content h1 { font: bold 18px/24px "Times New Roman", Times, serif; margin: 2px 0 8px; }
.helpwin .content h2 { font: bold 15px/20px "Times New Roman", Times, serif; margin: 12px 0 4px; }
.helpwin .content p { margin: 0 0 8px; }
.helpwin .content a.jump { color: #008000; text-decoration: underline; cursor: var(--cur-hand), pointer; }
.helpwin .content a.pop { color: #008000; text-decoration: underline dotted; cursor: var(--cur-hand), pointer; }
.helpwin .content table { border-collapse: collapse; margin: 4px 0 8px; }
.helpwin .content td { padding: 1px 12px 1px 0; vertical-align: top; }
.helpwin .content kbd { font: bold 13px Arial, sans-serif; }

/* about box art */
.aboutart { width: 96px; height: 96px; image-rendering: pixelated; border: 1px solid var(--black); }
.hr { height: 1px; background: var(--black); margin: 8px 0; }

/* tooltip-free; visually hidden helper */
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
