/* 16 Colors — shared Windows 95-style chrome.
   Faithful structure (2px bevels, Tahoma, menu bars) in a muted, modern palette drawn from the
   games' colours rather than raw VGA primaries. Like Windows 3.1's Control Panel → Color, the
   palette comes in named schemes (picked in the Color program, synced as prefs:appearance);
   win.js sets html[data-scheme] for any but the default. */
:root, [data-scheme="default"] {
  /* Scheme tokens: "16 Colors", the default. */
  --desk: #2f6461;          /* desktop */
  --face: #d8d3c6;          /* window face */
  --light: #ebe7dd;
  --white: #fbf9f3;
  --shadow: #8b8576;
  --black: #1c1c22;
  --ink: #1c1c22;
  --ink-off: #7f796c;
  --field: #fefdf9;
  --title: #28457f;         /* selection and highlighted menu items */
  --title-a: #203a6c;       /* active title bar, left to right */
  --title-b: #3d6aa6;
  --title-ink: #ffffff;
  --title-off: #6b6e76;     /* inactive title bar */
  --title-off-b: #7d8087;
  --title-off-ink: #eeebe3;
  --mark: #e3b453;          /* the "16" on the Start menu banner */
  --ok: #2f9e66;            /* synced */
  --busy: #c58a1c;          /* syncing */
  --alert: #b3312b;         /* PREVIEW badge */
}
/* Built from the scheme tokens; repeated on [data-scheme] so a preview element can wear another scheme. */
:root, [data-scheme] {
  --title-grad: linear-gradient(90deg, var(--title-a), var(--title-b));
  --title-off-grad: linear-gradient(90deg, var(--title-off), var(--title-off-b));
  --raised: inset -1px -1px var(--black), inset 1px 1px var(--white), inset -2px -2px var(--shadow), inset 2px 2px var(--light);
  --sunken: inset -1px -1px var(--white), inset 1px 1px var(--shadow), inset -2px -2px var(--light), inset 2px 2px var(--black);
  --pressed: inset -1px -1px var(--white), inset 1px 1px var(--black), inset -2px -2px var(--light), inset 2px 2px var(--shadow);
  --thin-in: inset -1px -1px var(--white), inset 1px 1px var(--shadow);
  --thin-out: inset -1px -1px var(--shadow), inset 1px 1px var(--white);
}
/* The original greyscale chrome. */
[data-scheme="classic"] {
  --desk: #5e5e5e; --face: #c0c0c0; --light: #dfdfdf; --white: #ffffff; --shadow: #808080; --black: #000000;
  --ink: #000000; --ink-off: #808080; --field: #ffffff;
  --title: #2a2a2a; --title-a: #2a2a2a; --title-b: #2a2a2a; --title-ink: #ffffff;
  --title-off: #808080; --title-off-b: #808080; --title-off-ink: #c0c0c0;
  --mark: #ffffff; --ok: #808080; --busy: #000000; --alert: #000000;
}
/* Deep water: slate-blue desktop, teal titles, cool grey faces. */
[data-scheme="ocean"] {
  --desk: #27405e; --face: #cdd3d4; --light: #e3e8e8; --white: #f7fafa; --shadow: #7c878a; --black: #1a1f26;
  --ink: #1a1f26; --ink-off: #737e81; --field: #fbfdfd;
  --title: #1d5c5e; --title-a: #17494c; --title-b: #2f7f7c; --title-ink: #ffffff;
  --title-off: #66707a; --title-off-b: #7b848d; --title-off-ink: #eef1f2;
  --mark: #8fd0c4;
}
/* Desert: adobe desktop, brick titles, sand faces. */
[data-scheme="arizona"] {
  --desk: #7a4f3a; --face: #ddd1ba; --light: #ede4d2; --white: #fcf8ee; --shadow: #948669; --black: #23201b;
  --ink: #23201b; --ink-off: #857a62; --field: #fffcf4;
  --title: #8e2f28; --title-a: #7f2722; --title-b: #b0533f; --title-ink: #ffffff;
  --title-off: #7a7064; --title-off-b: #8b8174; --title-off-ink: #f3ede2;
  --mark: #f0c46a; --alert: #1f7a4c;
}
/* Black Leather Jacket: near-black desktop, plum titles, cool grey faces. */
[data-scheme="leather"] {
  --desk: #26242b; --face: #cfcace; --light: #e4e0e3; --white: #f9f7f8; --shadow: #827b81; --black: #1c1c22;
  --ink: #1c1c22; --ink-off: #7a737a; --field: #fdfcfd;
  --title: #6e2f59; --title-a: #5e2a4d; --title-b: #94487a; --title-ink: #ffffff;
  --title-off: #5d5a61; --title-off-b: #7c7980; --title-off-ink: #ecebee;
  --mark: #e0a3c8;
}
/* Hot Dog Stand, toned down: mustard and ketchup, still loud. */
[data-scheme="hotdog"] {
  --desk: #a8332b; --face: #e8cf86; --light: #f3e3b0; --white: #fff8e0; --shadow: #a08542; --black: #1c1c22;
  --ink: #1c1c22; --ink-off: #8a7236; --field: #fff9e6;
  --title: #1c1c22; --title-a: #1c1c22; --title-b: #3a3a44; --title-ink: #f3d36b;
  --title-off: #8a3a2f; --title-off-b: #a5574a; --title-off-ink: #fbe7b5;
  --mark: #f3d36b; --ok: #1f7a4c; --busy: #1c1c22; --alert: #1c1c22;
}
:root {
  --font-ui: Tahoma, "MS Sans Serif", "Microsoft Sans Serif", Geneva, Verdana, sans-serif;
  --font-tile: Arial, "Helvetica Neue", Helvetica, sans-serif;
  color-scheme: light;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--desk); }
body {
  margin: 0;
  padding-block: 24px 40px;
  padding-inline: 16px;
  background: var(--desk);
  color: var(--ink);
  font: 12px/1.35 var(--font-ui);
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; }

/* ---------- window ---------- */
.win {
  max-width: 1000px;
  margin-inline: auto;
  padding: 3px;
  background: var(--face);
  box-shadow: var(--raised);
}
.titlebar {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 2px 0 3px;
  background: var(--title-grad);
  color: var(--title-ink);
}
.titlebar.inactive { background: var(--title-off-grad); color: var(--title-off-ink); }
.titlebar h1, .titlebar h2 { flex: 1; margin: 0; font: 700 12px/1 var(--font-ui); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-icon { width: 14px; height: 14px; flex: none; }
.app-icon svg { display: block; width: 100%; height: 100%; }
.caption-btns { display: flex; }
.caption-btns > * {
  display: grid;
  place-items: center;
  width: 16px;
  height: 14px;
  background: var(--face);
  box-shadow: var(--raised);
  color: var(--ink);
  font: 700 10px/1 var(--font-ui);
  text-decoration: none;
}
.caption-btns > :last-child { margin-left: 2px; }
.caption-btns > a:active { box-shadow: var(--pressed); }
.caption-btns > a:focus-visible { outline: 1px dotted var(--ink); outline-offset: -3px; }

/* ---------- menu bar ---------- */
.menubar { display: flex; flex-wrap: wrap; padding: 1px 0; position: relative; z-index: 40; }
.menu { position: relative; }
.menu-title {
  appearance: none;
  border: 0;
  background: none;
  font: 12px/1 var(--font-ui);
  color: var(--ink);
  padding: 4px 8px;
  cursor: default;
}
.menu-title u, .mi u { text-decoration: underline; text-underline-offset: 1px; }
.menu.open .menu-title { background: var(--title); color: var(--title-ink); }
.menu-title:focus-visible { outline: 1px dotted var(--ink); outline-offset: -2px; }
.menu.right { margin-left: auto; }
.menu.right .dropdown { left: auto; right: 0; }
.dropdown {
  position: absolute;
  left: 0;
  top: 100%;
  min-width: 190px;
  padding: 3px;
  background: var(--face);
  box-shadow: var(--raised);
  display: none;
}
.menu.open .dropdown { display: block; }
.mi {
  appearance: none;
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  width: 100%;
  border: 0;
  background: none;
  padding: 4px 10px 4px 2px;
  font: 12px/1.2 var(--font-ui);
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  cursor: default;
}
.mi .chk { text-align: center; font-size: 11px; }
.mi .key { padding-left: 20px; }
.mi:hover:not(:disabled), .mi:focus-visible { background: var(--title); color: var(--title-ink); outline: none; }
.mi:disabled { color: var(--ink-off); text-shadow: 1px 1px 0 var(--white); }
.mi-note { padding: 4px 10px 4px 20px; color: var(--ink-off); white-space: nowrap; }
.sep { height: 2px; margin: 3px 1px; border-top: 1px solid var(--shadow); border-bottom: 1px solid var(--white); }

/* ---------- controls ---------- */
.btn {
  appearance: none;
  min-width: 75px;
  padding: 5px 12px;
  border: 0;
  background: var(--face);
  box-shadow: var(--raised);
  font: 12px/1 var(--font-ui);
  color: var(--ink);
  text-decoration: none;
  display: inline-block;
  text-align: center;
}
.btn:active { box-shadow: var(--pressed); padding: 6px 11px 4px 13px; }
.btn:focus-visible { outline: 1px dotted var(--ink); outline-offset: -5px; }
.btn.default { box-shadow: 0 0 0 1px var(--black), var(--raised); }

/* ---------- message box ---------- */
.dialog {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  z-index: 30;
  width: min(330px, calc(100% - 8px));
  padding: 3px;
  background: var(--face);
  box-shadow: var(--raised), 2px 2px 0 rgba(0, 0, 0, .35);
}
.dlg-body { display: flex; align-items: flex-start; gap: 14px; padding: 16px 14px 8px; }
.dlg-icon { flex: none; width: 34px; height: 34px; }
.dlg-icon svg { display: block; width: 100%; height: 100%; }
.dlg-copy { min-width: 0; display: grid; gap: 6px; }
.dlg-copy p { margin: 0; }
.dlg-big { font-weight: 700; }
.dlg-actions { display: flex; justify-content: center; gap: 8px; padding: 8px 14px 12px; }

/* ---------- status bar ---------- */
.statusbar { display: flex; flex-wrap: wrap; gap: 2px; padding-top: 2px; }
.field {
  padding: 3px 6px;
  box-shadow: var(--thin-in);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.field.grow { flex: 1 1 10rem; min-width: 0; white-space: normal; }
@media (max-width: 480px) { .field.grow { flex-basis: 3rem; } }

/* ---------- running inside a desktop window: the desktop draws the frame and title bar ---------- */
html.embedded, html.embedded body { height: 100%; }
html.embedded { padding: 0; }
html.embedded body { padding: 0; background: var(--face); }
html.embedded .win {
  display: flex;
  flex-direction: column;
  max-width: none;
  height: 100%;
  padding: 0 2px 2px;
  box-shadow: none;
}
html.embedded .win > .titlebar { display: none; }
html.embedded .win > .client { flex: 1; min-height: 0; overflow: auto; }
