/* A restrained nod to Workbench: the Amiga's blue/orange, without cosplay. */
:root {
  --bg: #f4f4f6;
  --panel: #ffffff;
  --ink: #14161c;
  --muted: #5d6473;
  --line: #d9dce4;
  --accent: #0a5ad4;
  --accent-ink: #ffffff;
  --warn: #b45309;
  --bad: #b42318;
  --good: #027a48;
  --radius: 6px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161c; --panel: #1d2029; --ink: #e8eaf0; --muted: #9aa3b5;
    --line: #2e3340; --accent: #5b9bff; --accent-ink: #08101f;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
/* A normal monospace for data the reader has to compare character by
   character, such as hashes. Topaz is a chunky 8x8 bitmap face -- excellent
   for a directory listing, poor for a 64-character hex string. */
code, .mono {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
/* Topaz for things that were Amiga text: volume names and filenames. */
.amiga {
  font-family: "Topaz Unicode", ui-monospace, monospace;
}
header.top {
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 0 20px; position: sticky; top: 0; z-index: 10;
}
header.top .row {
  max-width: 1100px; margin: 0 auto; display: flex; align-items: center;
  gap: 20px; height: 56px;
}
header.top .brand { font-weight: 700; font-size: 17px; text-decoration: none; color: var(--ink); }
header.top nav { display: flex; gap: 16px; margin-left: auto; }
header.top nav a { text-decoration: none; color: var(--muted); font-size: 14px; }
header.top nav a:hover, header.top nav a.on { color: var(--accent); }
main { max-width: 1100px; margin: 24px auto 64px; padding: 0 20px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 28px 0 10px; }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}
.grid { display: grid; gap: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px;
     text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: rgba(127,127,127,.06); }
.scroll { overflow-x: auto; }
.chip {
  display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.chip.ok { color: var(--good); border-color: currentColor; }
.chip.warn { color: var(--warn); border-color: currentColor; }
.chip.bad { color: var(--bad); border-color: currentColor; }
.btn {
  display: inline-block; background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: var(--radius); padding: 9px 16px; font-size: 14px;
  cursor: pointer; text-decoration: none;
}
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
input[type=text], input[type=password], input[type=search], select {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); color: var(--ink); font-size: 14px; width: 100%;
}
#drop {
  border: 2px dashed var(--line); border-radius: 10px; padding: 40px 20px;
  text-align: center; color: var(--muted); background: var(--panel);
  transition: border-color .15s, background .15s;
}
#drop.hot { border-color: var(--accent); background: rgba(10,90,212,.05); }
.filelist { margin-top: 16px; display: grid; gap: 6px; }
.filerow {
  display: grid; grid-template-columns: 1fr 110px 90px; gap: 10px;
  align-items: center; font-size: 13px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
}
.filerow .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.tree { font-size: 13px; line-height: 1.7; }
.tree .d { color: var(--muted); }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.flash.err { background: rgba(180,35,24,.1); color: var(--bad); }
.flash.ok { background: rgba(2,122,72,.1); color: var(--good); }
.muted { color: var(--muted); }
.right { text-align: right; }
footer { color: var(--muted); font-size: 12px; text-align: center; padding: 30px 0; }

/* --- Amiga Shell window -------------------------------------------------
   Workbench 1.3's four-colour palette: blue ground, white, black and orange.
   Topaz is the Kickstart 1.3 system font, served as a webfont because the
   viewer's machine will not have it. */
@font-face {
  font-family: "Topaz Unicode";
  src: url("/static/fonts/topaz_unicode_ks13_regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Topaz Unicode";
  src: url("/static/fonts/topaz_unicode_ks13_bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --wb-blue: #0055aa;
  --wb-white: #ffffff;
  --wb-black: #000000;
  --wb-orange: #ff8800;
}

/* The window hugs its contents rather than stretching to the page width --
   a Shell window is as wide as the text in it. */
.amiwin {
  display: inline-block;
  max-width: 100%;
  background: var(--wb-blue);
  border: 2px solid var(--wb-white);
  /* Topaz is an 8x8 face and Amiga listings had no leading, so keep the
     lines tight -- 1.15 is dense like the real thing but still readable
     on a modern display. */
  font: 16px/1.15 "Topaz Unicode", ui-monospace, monospace;
  /* Topaz is an 8x8 bitmap face; disabling smoothing keeps it crisp. */
  -webkit-font-smoothing: none;
  font-smooth: never;
}
.amiwin .bar {
  display: flex;
  align-items: stretch;
  background: var(--wb-white);
  color: var(--wb-blue);
  border-bottom: 2px solid var(--wb-white);
  height: 22px;
}
.amiwin .bar .title {
  flex: 1 1 auto;
  padding: 2px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 700;
}
/* Close gadget on the left, depth and zoom gadgets on the right, as on a
   real Workbench window. */
.amiwin .gadget {
  flex: 0 0 auto;
  width: 22px;
  border-right: 2px solid var(--wb-blue);
  position: relative;
}
.amiwin .gadget.right { border-right: 0; border-left: 2px solid var(--wb-blue); }
.amiwin .gadget.close::after {
  content: ""; position: absolute; inset: 6px;
  background: var(--wb-blue);
}
.amiwin .gadget.depth::after {
  content: ""; position: absolute; inset: 5px 4px;
  background: var(--wb-blue);
  box-shadow: inset -5px 5px 0 0 var(--wb-white);
}
.amiwin pre {
  margin: 0;
  padding: 6px 10px 8px;
  color: var(--wb-white);
  /* A Shell window scrolls rather than growing without limit; a 60-entry
     disk would otherwise push the rest of the page off the screen. */
  max-height: 70vh;
  overflow: auto;
  white-space: pre;
  font: inherit;
}
.amiwin a { color: var(--wb-orange); text-decoration: none; }
.amiwin a:hover { color: var(--wb-blue); background: var(--wb-orange); }
.amiwin .dirname { color: var(--wb-white); font-weight: 700; }
.amiwin .linkname { color: #88ccff; }
.amiwin .comment { color: var(--wb-orange); }
.amiwin .foot { color: #aaddff; }

/* --- File viewer dialog --------------------------------------------------
   A native <dialog>, so focus trapping, Escape-to-close and the backdrop come
   from the browser rather than from script. */
#viewer {
  padding: 0;
  border: 2px solid var(--wb-white);
  background: var(--wb-blue);
  color: var(--wb-white);
  width: min(92vw, 860px);
  max-height: 86vh;
  overflow: hidden;               /* the body scrolls, not the dialog */
  display: flex;
  flex-direction: column;
  font: 16px/1.15 "Topaz Unicode", ui-monospace, monospace;
  -webkit-font-smoothing: none;
  font-smooth: never;
}
#viewer:not([open]) { display: none; }
#viewer::backdrop { background: rgba(0, 0, 0, .55); }

#viewer .bar {
  display: flex; align-items: stretch; height: 22px; flex: 0 0 auto;
  background: var(--wb-white); color: var(--wb-blue);
}
#viewer .bar .title {
  flex: 1 1 auto; padding: 2px 8px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#viewer .gadget { flex: 0 0 auto; width: 22px; position: relative; cursor: pointer;
                  border-right: 2px solid var(--wb-blue); }
#viewer .gadget.close::after {
  content: ""; position: absolute; inset: 6px; background: var(--wb-blue);
}

/* The scrolling region. overscroll-behavior stops the page behind from
   scrolling once this reaches its end. */
#viewer .viewer-body {
  flex: 1 1 auto;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 10px 12px;
  min-height: 0;                  /* lets a flex child actually shrink */
}
#viewer .viewer-body pre {
  margin: 0; white-space: pre-wrap; word-break: break-word; font: inherit;
}
#viewer .viewer-warn {
  margin: 0 0 10px; padding: 6px 8px;
  background: var(--wb-orange); color: var(--wb-black);
}
#viewer .viewer-note { margin: 10px 0 0; color: #aaddff; }
#viewer .viewer-loading { padding: 24px; text-align: center; color: #aaddff; }

#viewer .viewer-foot {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 8px 12px;
  border-top: 2px solid var(--wb-white);
  font: 13px/1.4 system-ui, sans-serif;
  color: #cfe6ff;
}
#viewer .viewer-foot .viewer-hash { font-size: 12px; color: #9fc9f0; }
#viewer .viewer-foot a { color: var(--wb-orange); margin-left: auto; }
#viewer .viewer-foot .btn.ghost {
  border-color: var(--wb-white); color: var(--wb-white); padding: 5px 12px;
}
#viewer .viewer-foot .btn.ghost:hover { background: var(--wb-white); color: var(--wb-blue); }
