/* Early-1990s desktop look. Hand-written, no external assets. */
:root {
  --desktop: #a8a8a8;
  --face: #c0c0c0;
  --shadow: #808080;
  --dark: #000000;
  --hi: #ffffff;
  --title: #a6caf0;
  --title-text: #000000;
  --title-off: #ffffff;
  --title-off-text: #000000;
  --client: #ffffff;
  --text: #000000;
  --sel: #000080;
  --sel-text: #ffffff;
  --mark: #ffff00;
  --ui: "MS Sans Serif", "Microsoft Sans Serif", "Segoe UI", Tahoma, Arial, sans-serif;
  --mono: "Fixedsys", "Courier New", Courier, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--desktop);
  color: var(--text);
  font: bold 12px/1.35 var(--ui);
  overflow: hidden;
  -webkit-font-smoothing: none;
}
.desktop { position: relative; width: 100%; height: 100%; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
u { text-decoration: underline; }
a { color: #0000ee; }
a:visited { color: #551a8b; }
:focus-visible { outline: 1px dotted var(--dark); outline-offset: 1px; }

/* ---- windows ---- */
.win {
  position: absolute;
  display: flex; flex-direction: column;
  max-width: calc(100vw - 8px);
  max-height: calc(100vh - 8px);
  background: var(--face);
  border: 1px solid var(--dark);
  box-shadow: inset 0 0 0 1px var(--face), inset 0 0 0 3px var(--face), inset 0 0 0 4px var(--dark);
  padding: 4px;
}
.win.hidden, .win.minimized { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.win.maxed { left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important; max-width: none; max-height: none; }
.titlebar {
  display: flex; align-items: stretch; height: 20px; flex: none;
  border: 1px solid var(--dark);
  background: var(--title-off); color: var(--title-off-text);
  cursor: default; user-select: none; touch-action: none;
}
.win.active .titlebar { background: var(--title); color: var(--title-text); }
.title {
  flex: 1; margin: 0; font: inherit; font-size: 13px;
  text-align: center; line-height: 18px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sysmenu, .tb-btn {
  width: 20px; flex: none; padding: 0; margin: 0;
  background: var(--face); border: 0; border-right: 1px solid var(--dark);
  position: relative; cursor: pointer;
}
.tb-btn { border-right: 0; border-left: 1px solid var(--dark); box-shadow: inset 1px 1px 0 var(--hi), inset -1px -1px 0 var(--shadow); }
.tb-btn:active { box-shadow: inset 1px 1px 0 var(--shadow); }
.sysmenu::after { content: ""; position: absolute; left: 4px; right: 4px; top: 8px; height: 3px; background: var(--hi); border: 1px solid var(--dark); }
.tb-btn.min::after, .tb-btn.max::after { content: ""; position: absolute; left: 5px; border: 4px solid transparent; }
.tb-btn.min::after { top: 7px; border-top: 5px solid var(--dark); }
.tb-btn.max::after { top: 2px; border-bottom: 5px solid var(--dark); }
.win.maxed .tb-btn.max::after { top: 0; border-bottom: 4px solid var(--dark); }
.win.maxed .tb-btn.max::before { content: ""; position: absolute; left: 5px; top: 10px; border: 4px solid transparent; border-top: 4px solid var(--dark); }
.tb-btn.close::after { content: "×"; position: absolute; inset: 0; font: bold 15px/18px var(--ui); color: var(--dark); }

.menubar { display: flex; flex-wrap: wrap; background: var(--client); border: 1px solid var(--dark); border-top: 0; flex: none; }
.menubar button { font: inherit; background: none; border: 0; padding: 2px 8px; cursor: pointer; color: var(--text); }
.menubar button:hover, .menubar button:focus-visible { background: var(--sel); color: var(--sel-text); outline: none; }

.client {
  flex: 1; min-height: 0; overflow: auto;
  background: var(--face);
  border: 1px solid var(--dark); border-top: 0;
  padding: 8px;
}
.titlebar + .client { border-top: 0; }
.statusbar {
  display: flex; justify-content: space-between; gap: 8px; flex: none;
  padding: 2px 6px; margin-top: 3px; font-weight: normal;
  border: 1px solid var(--shadow); border-right-color: var(--hi); border-bottom-color: var(--hi);
}

/* program group */
.group { background: #fffbf0; display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px 4px; padding: 12px 6px; }
.icon {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font: inherit; font-weight: normal; color: var(--text); text-decoration: none; text-align: center;
  background: none; border: 0; padding: 2px; cursor: pointer;
}
.icon:visited { color: var(--text); }
.icon:focus-visible, .icon:hover { outline: none; }
.icon:focus-visible .glyph + *, .icon:focus-visible { background: transparent; }
.icon:focus-visible { box-shadow: 0 0 0 1px var(--dark) inset; }
.glyph { width: 32px; height: 32px; display: block; image-rendering: pixelated; }
/* icons: small inline SVGs (CSS-gradient icons drew black in iOS Safari) */
.g-find { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Ccircle cx='12' cy='12' r='7.5' fill='%239cf' stroke='%23000' stroke-width='2'/%3E%3Cpath d='M17.5 17.5 L27 27' stroke='%23800000' stroke-width='4.5' stroke-linecap='square'/%3E%3Ccircle cx='10' cy='10' r='2' fill='%23fff'/%3E%3C/svg%3E") center / 32px 32px no-repeat; }
.g-card { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' shape-rendering='crispEdges'%3E%3Crect x='7.5' y='3.5' width='21' height='15' fill='%23ffffa0' stroke='%23000'/%3E%3Crect x='3.5' y='10.5' width='23' height='17' fill='%23fff' stroke='%23000'/%3E%3Cpath d='M3.5 14.5h23' stroke='%23c00'/%3E%3C/svg%3E") center / 32px 32px no-repeat; }
.g-note { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' shape-rendering='crispEdges'%3E%3Crect x='6.5' y='2.5' width='19' height='27' fill='%23fff' stroke='%23000'/%3E%3Cpath d='M9 8h14M9 12h14M9 16h14M9 20h14M9 24h10' stroke='%23808080'/%3E%3C/svg%3E") center / 32px 32px no-repeat; }
.g-help { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Ccircle cx='16' cy='16' r='12' fill='%23ff0' stroke='%23000' stroke-width='2'/%3E%3Ctext x='16' y='22' font-family='Arial,Helvetica,sans-serif' font-weight='bold' font-size='17' text-anchor='middle' fill='%23000'%3E%3F%3C/text%3E%3C/svg%3E") center / 32px 32px no-repeat; }
.g-scan { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' shape-rendering='crispEdges'%3E%3Crect x='5.5' y='2.5' width='21' height='27' fill='%23f4ecd0' stroke='%23000'/%3E%3Cpath d='M9 7h14M9 11h14M9 15h10M9 19h14M9 23h8' stroke='%23aaa' stroke-width='1.5'/%3E%3C/svg%3E") center / 32px 32px no-repeat; }
.g-disk { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' shape-rendering='crispEdges'%3E%3Crect x='4' y='4' width='24' height='24' fill='%23202020'/%3E%3Crect x='10' y='5' width='12' height='9' fill='%23c0c0c0'/%3E%3Crect x='18' y='6' width='2.5' height='6' fill='%23202020'/%3E%3Crect x='8' y='18' width='16' height='10' fill='%23fff'/%3E%3C/svg%3E") center / 32px 32px no-repeat; }

/* dialogs and controls */
.dialog { display: grid; gap: 6px; grid-template-columns: minmax(0, 1fr); }
.dialog > *, fieldset { min-width: 0; min-inline-size: 0; }
input, select { min-width: 0; }
.dialog.inline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.dialog.inline input { flex: 1 1 200px; }
.row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.lbl { width: 108px; flex: none; }
input[type=search], input[type=number], select {
  font: normal 12px var(--ui); color: var(--text);
  background: var(--client); border: 1px solid var(--dark);
  box-shadow: inset 1px 1px 0 var(--shadow);
  padding: 3px 4px; border-radius: 0; min-height: 23px;
}
input[type=search] { flex: 1 1 220px; -webkit-appearance: none; appearance: none; }
select { flex: 1 1 220px; max-width: 100%; }
.yr { display: flex; align-items: center; gap: 6px; }
.yr input { width: 72px; }
.group-box { border: 1px solid var(--shadow); box-shadow: 1px 1px 0 var(--hi); margin: 4px 0 0; padding: 4px 10px 6px; gap: 6px 16px; }
.group-box legend { padding: 0 3px; }
.group-box label { display: inline-flex; align-items: center; gap: 4px; font-weight: normal; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.btn {
  font: bold 12px var(--ui); color: var(--text); min-width: 76px; min-height: 24px;
  background: var(--face); border: 1px solid var(--dark); border-radius: 3px;
  box-shadow: inset 1px 1px 0 var(--hi), inset -2px -2px 0 var(--shadow);
  padding: 2px 10px; cursor: pointer;
}
.btn.default { border-width: 2px; }
.btn:active { box-shadow: inset 1px 1px 0 var(--shadow); padding: 3px 9px 1px 11px; }

/* list box */
.listhead, .listbox li { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 2fr) 54px 40px; gap: 8px; }
.listhead { margin-top: 10px; padding: 2px 6px; border: 1px solid var(--dark); border-bottom: 0; background: var(--face); box-shadow: inset 1px 1px 0 var(--hi); }
.listbox {
  list-style: none; margin: 0; padding: 0; background: var(--client);
  border: 1px solid var(--dark); box-shadow: inset 1px 1px 0 var(--shadow);
  height: 260px; overflow: auto; font-weight: normal;
}
.listbox li { padding: 1px 6px; cursor: pointer; }
.listbox li > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.listbox li[aria-selected=true] { background: var(--sel); color: var(--sel-text); }
.listbox li[aria-selected=true] mark { background: transparent; color: inherit; text-decoration: underline; }
.listbox li.empty { display: block; color: var(--shadow); cursor: default; }
.listbox.narrow li { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
mark { background: var(--mark); color: var(--dark); }

/* cards: record viewer, agency card, about */
.card { background: #ffffe8; font-weight: normal; }
.client.card { border: 1px solid var(--dark); }
.card h3 { margin: 0 0 6px; font-size: 13px; padding-bottom: 4px; border-bottom: 1px solid #c00; }
.card dl { margin: 0; display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 6px 10px; }
.card dt { font-weight: bold; }
.card dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.card .apps { margin: 6px 0 0; padding-left: 18px; }
.card .apps a { cursor: pointer; }
.prose p { margin: 0 0 8px; }
.small { font-size: 11px; color: #333; }
.split { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 8px; }
.split .listbox { height: 100%; min-height: 0; }
#w-agencies .split { height: 380px; flex: none; }
#w-text .notepad { height: 220px; }
.split .card { border: 1px solid var(--dark); padding: 8px; overflow: auto; min-height: 300px; }

/* notepad */
.notepad {
  background: var(--client); border: 1px solid var(--dark); box-shadow: inset 1px 1px 0 var(--shadow);
  font: normal 13px/1.4 var(--mono); padding: 6px; height: 300px; overflow: auto;
}
.notepad .hit { padding: 4px 0 6px; border-bottom: 1px dashed var(--shadow); white-space: pre-wrap; overflow-wrap: anywhere; }
.notepad .ln { color: var(--shadow); }
.notepad .where { font-family: var(--ui); font-size: 11px; color: #444; }
.notepad .where button { font: inherit; background: none; border: 0; padding: 0; color: #0000ee; text-decoration: underline; cursor: pointer; }
.hint { margin: 6px 0; font-weight: normal; }

/* BetaNYC logo and donation */
.glyph.logo { background: var(--hi); border: 1px solid var(--dark); padding: 0; transform: none; }
.glyph.logo, .msgbox .msg img { object-fit: cover; object-position: 50% 50%; }
.donate-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 6px; border: 1px solid var(--shadow); background: var(--hi); }
.msgbox { position: fixed; inset: 0; margin: auto; width: min(380px, calc(100vw - 32px)); height: fit-content; color: var(--text); flex-direction: column;
  background: var(--face); border: 1px solid var(--dark); padding: 4px;
  box-shadow: inset 0 0 0 3px var(--face), inset 0 0 0 4px var(--dark); }
.msgbox::backdrop { background: transparent; }
.msgbox[open] { display: flex; }
.msgbox .titlebar { background: var(--title); color: var(--title-text); }
.msgbox .msg { display: flex; align-items: center; gap: 14px; padding: 8px 4px 12px; font-size: 13px; }
.msgbox .msg p { margin: 0; }
.btns.center { justify-content: center; }
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: var(--text); }
a.btn:visited { color: var(--text); }

/* scan viewer and file list */
.client.scan { padding: 0; display: flex; }
.client.scan iframe { flex: 1; width: 100%; min-height: 360px; border: 0; background: var(--shadow); }
.statusbar a { font-weight: normal; }
.listbox.files { height: auto; max-height: 300px; }
.listbox.files li { display: grid; grid-template-columns: 18px minmax(0, 1.4fr) 70px minmax(0, 2fr); gap: 8px; align-items: center; cursor: default; }
.listbox.files li a { color: inherit; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.listbox.files li a:hover, .listbox.files li a:focus-visible { background: var(--sel); color: var(--sel-text); outline: none; }
.listbox.files .sz { text-align: right; font-variant-numeric: tabular-nums; }
.listbox.files .desc { color: #333; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fi { width: 14px; height: 16px; border: 1px solid var(--dark); background: var(--hi); position: relative; }
.fi::after { content: ""; position: absolute; left: 2px; right: 2px; top: 4px; height: 6px; background: repeating-linear-gradient(var(--shadow) 0 1px, transparent 1px 3px); }
.brandhead { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.brandhead h3 { margin: 0; border: 0; padding: 0; }
.prose .gap { margin-top: 14px; }

/* minimized-window icons */
.tray { position: absolute; left: 8px; bottom: 8px; display: flex; gap: 12px; flex-wrap: wrap; }
.tray button {
  display: flex; flex-direction: column; align-items: center; gap: 3px; width: 84px;
  font: normal 11px var(--ui); color: var(--hi); background: none; border: 0; cursor: pointer; text-align: center;
}
.tray .glyph { background-color: var(--face); border: 1px solid var(--dark); box-shadow: inset 1px 1px 0 var(--hi), inset -1px -1px 0 var(--shadow); }
.tray button { color: var(--dark); }
.tray span.cap { background: transparent; padding: 0 3px; }

/* phones: windows become a stack of full-width panels */
/* Stacked layout: phones, and the accessible view on any screen. JS sets body.stack. */
body.stack { overflow: auto; }
body.stack .desktop { height: auto; min-height: 100%; padding: 8px 8px 96px; display: flex; flex-direction: column; gap: 10px; }
body.stack .win { position: relative; left: auto !important; top: auto !important; width: 100% !important; max-width: none; max-height: none; }
body.stack .win.maxed { height: auto !important; }
body.stack .tb-btn.max { display: none; }
body.stack .lbl { width: 100%; }
body.stack .listhead, body.stack .listbox li { grid-template-columns: minmax(0, 1fr) 46px 34px; }
body.stack .listhead span:nth-child(2), body.stack .listbox li > span:nth-child(2) { display: none; }
body.stack .split { grid-template-columns: 1fr; }
body.stack .split .listbox { min-height: 0; height: 180px; }
body.stack #w-agencies .split { height: auto; }
body.stack .card dl { grid-template-columns: 1fr; gap: 2px; }
body.stack .card dd { margin-bottom: 6px; }
body.stack .tray { position: fixed; }
body.stack .listbox.files li { grid-template-columns: 18px minmax(0, 1fr) 64px; }
body.stack .listbox.files .desc { display: none; }
body.stack .client.scan iframe { min-height: 420px; }
body.stack .win.hidden, body.stack .win.minimized { display: none; }

/* Larger reading text in the About windows */
.prose { font-size: 15px; line-height: 1.45; }
body.stack .prose { font-size: 17px; }
.donate-line { flex-wrap: nowrap; }
.donate-line img { flex: none; }
.donate-line span { min-width: 0; }

/* Accessible view: bigger plain text, no overlapping, no pop-up */
body.plain { -webkit-font-smoothing: auto; }
body.plain .win, body.plain .win * { font-size: 17px !important; line-height: 1.5; }
body.plain .win .title { font-size: 18px !important; }
body.plain .titlebar { height: auto; min-height: 30px; }
body.plain .tb-btn, body.plain .sysmenu { width: 30px; }
body.plain .listhead, body.plain .listbox li { grid-template-columns: minmax(0, 1fr) 64px 52px; padding: 4px 6px; }
body.plain .listbox { height: 340px; }
body.plain input[type=search], body.plain input[type=number], body.plain select { min-height: 36px; }
body.plain .btn { min-height: 40px; padding: 4px 14px; }
body.plain :focus-visible { outline: 3px solid #000; outline-offset: 2px; }
body.plain mark { outline: 1px solid #000; }

/* Skip links: hidden until focused */
.skip { position: absolute; left: 8px; top: -60px; z-index: 100000; display: flex; gap: 8px; }
.skip:focus-within { top: 8px; }
.skip a, .skip button { font: bold 14px var(--ui); background: var(--hi); color: var(--dark); border: 2px solid var(--dark); padding: 6px 10px; cursor: pointer; }
.menubar .view-toggle { margin-left: auto; }
