:root {
  --paper: #ffcf00;
  --ink: #300f0a;
  --screen: #300f0a;
  --screen-ink: #ffcf00;
  --hatch: repeating-linear-gradient(135deg, var(--ink) 0 1px, transparent 1px 4px);
  --bar: 32px;
  --dock: 48px;
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  font-size: 13px;
  color: var(--ink);
  background: var(--paper);
}
/* after dark at the desk (Tallinn time) the page goes to night */
:root.night { --paper: #1c0906; --ink: #ffcf00; --screen: #ffcf00; --screen-ink: #1c0906; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--paper); color: var(--ink); overflow: hidden; transition: background .8s, color .8s; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
hr { border: 0; border-top: 2px solid var(--ink); margin: 14px 0; }
.dim { opacity: .65; }
.small { font-size: 11px; }
.spacer { flex: 1; }

.menubar {
  position: fixed; left: 0; right: 0; z-index: 1000; height: var(--bar);
  display: flex; align-items: center; gap: 22px; padding: 0 18px;
  background: var(--paper); text-transform: uppercase; letter-spacing: .06em;
}
.menubar { top: 0; border-bottom: 2px solid var(--ink); }
.apple { color: inherit; text-decoration: none; font-size: 18px; }

.desktop { position: absolute; inset: var(--bar) 0 var(--dock) 0; }

.icon { display: grid; justify-items: center; gap: 4px; width: 92px; text-align: center; }
.icon svg { width: 48px; height: 48px; fill: var(--paper); stroke: var(--ink); stroke-width: 2.4; stroke-linejoin: round; }
.icon span { display: grid; font-size: 12px; padding: 1px 4px; }
.icon small { font-size: 11px; opacity: .7; }
.icon:hover span, .icon:focus-visible span { background: var(--ink); color: var(--paper); }

.win {
  position: absolute; background: var(--paper); border: 2px solid var(--ink);
  max-width: calc(100vw - 24px);
  animation: open .22s cubic-bezier(.2, .9, .3, 1.2);
}
.win::after {
  content: ""; position: absolute; inset: 10px -12px -12px 10px; pointer-events: none; background: var(--hatch);
  clip-path: polygon(calc(100% - 10px) 0, 100% 0, 100% 100%, 0 100%, 0 calc(100% - 10px), calc(100% - 10px) calc(100% - 10px));
}
.win[hidden] { display: none; }
.win.front .titlebar h2 { text-decoration: underline 2px; text-underline-offset: 4px; }
@keyframes open { from { transform: scale(.94); opacity: 0 } }
.titlebar { display: flex; align-items: center; gap: 14px; height: 30px; padding: 0 10px; border-bottom: 2px solid var(--ink); cursor: grab; user-select: none; touch-action: none; }
.titlebar:active { cursor: grabbing; }
.titlebar h2 { flex: 1; margin: 0; font-size: 13px; font-weight: 500; }
.boxes { display: flex; gap: 5px; }
.boxes > * { width: 13px; height: 13px; border: 2px solid var(--ink); display: grid; place-items: center; font-size: 0; line-height: 1; }
.boxes .close:hover, .boxes .min:hover { background: var(--ink); color: var(--paper); font-size: 11px; }
.pad { padding: 16px 18px 18px; }
.pad p { margin: 0 0 8px; line-height: 1.5; }
.label { text-transform: uppercase; letter-spacing: .08em; font-size: 11px; opacity: .7; }
.big { font-size: 17px; font-weight: 600; }

/* finder */
.finder { padding: 0 14px 16px; }
.path { margin: 0 -14px 14px; padding: 8px 14px; border-bottom: 2px solid var(--ink); font-size: 12px; }

/* media viewer */
.viewer { display: flex; flex-direction: column; height: min(640px, calc(100vh - 110px)); min-width: 320px; min-height: 300px; resize: both; overflow: hidden; }
.viewer[hidden] { display: none; }
.viewer-stage { flex: 1; min-height: 0; margin: 6px 6px 0; background: var(--screen); display: grid; place-items: center; overflow: hidden; }
.viewer-stage img, .viewer-stage video { max-width: 100%; max-height: 100%; display: block; animation: open .25s ease-out; }
.viewer-stage.actual { overflow: auto; place-items: start; }
.viewer-stage.actual img { max-width: none; max-height: none; }
.viewer-bar { display: flex; align-items: center; gap: 14px; padding: 8px 12px; border-bottom: 2px solid var(--ink); font-size: 12px; }
.viewer-bar button, .viewer-bar a { color: inherit; text-decoration: none; padding: 2px 6px; border: 2px solid transparent; }
.viewer-bar button:hover, .viewer-bar a:hover, .viewer-bar [aria-pressed="true"] { border-color: var(--ink); }
.viewer-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.viewer-strip { display: flex; gap: 6px; padding: 8px 10px 10px; overflow-x: auto; scrollbar-width: thin; }
.viewer-strip button { flex: 0 0 72px; height: 54px; border: 2px solid transparent; }
.viewer-strip button[aria-current] { border-color: var(--ink); }
.viewer-strip img, .viewer-strip video { width: 100%; height: 100%; object-fit: cover; display: block; filter: grayscale(1); opacity: .75; }
.viewer-strip button[aria-current] img, .viewer-strip button[aria-current] video, .viewer-strip button:hover img { filter: none; opacity: 1; }

.btn { border: 2px solid var(--ink); padding: 7px 14px; margin: 8px 0 6px; box-shadow: 3px 3px 0 var(--ink); }

/* drive: Robert's own folders, signed in with a passkey */
.account button { padding: 2px 5px; text-transform: uppercase; letter-spacing: .06em; }
.account button:hover, .account button:focus-visible { background: var(--ink); color: var(--paper); }
.transfer { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.transfer:empty { display: none; }
.drive { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.d-icon { position: absolute; pointer-events: auto; cursor: pointer; user-select: none; outline-offset: 2px; }
.d-icon span { max-width: 104px; }
.d-icon b { font-weight: 400; overflow-wrap: anywhere; }
.d-icon .thumb { width: 48px; height: 48px; object-fit: cover; border: 2px solid var(--ink); display: block; filter: grayscale(1) contrast(1.1); }
.d-icon:hover .thumb { filter: none; }
.d-icon.public svg { fill: var(--ink); }
.d-icon.public small::before { content: "◉ "; }
.d-icon[draggable="true"] { cursor: grab; }
.drop-on svg, .drop-on .thumb { transform: scale(1.12); fill: var(--ink); }
.drive-win.drop-on { outline: 3px dashed var(--ink); outline-offset: 4px; }
body.dropping .desktop { outline: 3px dashed var(--ink); outline-offset: -10px; }
body.dropping .desktop::after { content: "drop to put it on the desk"; position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 4px 10px; text-transform: uppercase; letter-spacing: .06em; font-size: 11px; z-index: 999; }
.rename { font: inherit; font-size: 12px; width: 100%; min-width: 0; max-width: 118px; border: 2px solid var(--ink); background: var(--paper); color: var(--ink); padding: 1px 3px; text-align: center; outline: 0; }

.drive-win .path { display: flex; align-items: center; gap: 10px; }
.drive-win .path button { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; padding: 1px 6px; border: 2px solid var(--ink); }
.drive-win .path button:hover, .drive-win .path [aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.drive-win .path button[hidden] { display: none; }
.tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px 8px; max-height: min(420px, calc(100vh - 220px)); overflow-y: auto; }
.tile { display: grid; justify-items: center; gap: 5px; padding: 4px 2px; text-align: center; font-size: 11px; cursor: pointer; }
.tile img, .tile video { width: 76px; height: 58px; object-fit: cover; border: 2px solid var(--ink); display: block; filter: grayscale(1) contrast(1.1); }
.tile svg { width: 44px; height: 58px; fill: var(--paper); stroke: var(--ink); stroke-width: 2.4; stroke-linejoin: round; }
.tile span { max-width: 100%; overflow-wrap: anywhere; line-height: 1.35; padding: 0 3px; }
.tile:hover img, .tile:hover video { filter: none; }
.tile:hover span, .tile:focus-visible span, .d-icon:focus-visible span { background: var(--ink); color: var(--paper); }
.drop-hint { display: none; margin: 6px 0 0; padding: 22px; border: 2px dashed var(--ink); text-align: center; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .6; }
.drive-win.empty .drop-hint, .drive-win.drop-on .drop-hint { display: block; }
.signed-in .drive-win .drop-hint { display: block; }
.signed-in .drive-win:not(.empty):not(.drop-on) .drop-hint { display: none; }

.file-win { display: flex; flex-direction: column; min-width: 300px; resize: both; overflow: hidden; }
.file-body { flex: 1; min-height: 0; margin: 6px 6px 0; }
.file-body pre { margin: 0; min-height: 140px; max-height: min(460px, calc(100vh - 200px)); overflow: auto; padding: 14px 16px; background: var(--screen); color: var(--screen-ink); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; font: inherit; font-size: 12px; }
.file-body.pdf iframe { width: 100%; height: min(640px, calc(100vh - 180px)); border: 0; display: block; background: #fff; }
.file-body.audio { padding: 14px 12px 8px; }
.file-body audio { width: 100%; }
.file-win .viewer-bar { border-bottom: 0; border-top: 2px solid var(--ink); margin-top: 6px; }

.menu { position: fixed; z-index: 3000; min-width: 170px; background: var(--paper); border: 2px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); padding: 4px 0; display: grid; }
.menu[hidden] { display: none; }
.menu button { text-align: left; padding: 5px 14px; font-size: 12px; }
.menu button:hover, .menu button:focus-visible { background: var(--ink); color: var(--paper); outline: 0; }
.menu hr { margin: 4px 0; border-top-width: 1px; }
.keylink code { display: block; padding: 8px 10px; background: var(--screen); color: var(--screen-ink); overflow-wrap: anywhere; font-size: 11px; }
.linkish { text-decoration: underline; }

/* dock: open and minimized windows; gone when there are none */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; height: var(--dock);
  display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 18px;
  background: var(--paper); border-top: 2px solid var(--ink); font-size: 11px;
}
.dock-windows { display: flex; align-items: center; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.dock-windows[hidden] { display: none; }
.dock button { position: relative; display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 9px; white-space: nowrap; }
.dock button span { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.dock svg { width: 18px; height: 18px; flex: none; fill: var(--paper); stroke: var(--ink); stroke-width: 3.2; stroke-linejoin: round; transition: transform .15s; }
.dock button:hover svg { transform: translateY(-2px); }
.dock button:hover, .dock button:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.dock button.running::after { content: ""; position: absolute; left: 50%; bottom: 1px; width: 4px; height: 4px; margin-left: -2px; background: var(--ink); }
.dock button.front { background: var(--ink); color: var(--paper); }
.dock button.front svg { fill: var(--ink); stroke: var(--paper); }
.dock button.front::after { background: var(--paper); }
.dock .transfer { position: absolute; right: 18px; max-width: 24vw; }
.dock:has(.dock-windows[hidden]):has(.transfer:empty) { display: none; }

@media (max-width: 1100px) { .dock button span { display: none; } .dock .transfer { display: none; } }
@media (max-width: 760px) {
  body { overflow: auto; }
  .desktop { position: static; padding: calc(var(--bar) + 12px) 16px calc(var(--dock) + 24px); display: grid; gap: 22px; }
  .win { position: relative; left: auto !important; top: auto !important; width: auto !important; max-width: none; margin-right: 10px; }
  .titlebar { cursor: default; }
  .dock { justify-content: flex-start; overflow-x: auto; }
  .menubar { gap: 12px; padding: 0 12px; font-size: 11px; }
  .menubar-clock, .account button { white-space: nowrap; }
  .viewer { position: fixed !important; inset: 0 !important; z-index: 2000 !important; height: auto; margin: 0; resize: none; }
  #viewer-fit { display: none; }
  .viewer .boxes .close { width: 22px; height: 22px; font-size: 14px; }
  .drive { position: static; display: flex; flex-wrap: wrap; gap: 14px; pointer-events: auto; }
  .drive:empty { display: none; }
  .d-icon { position: static; }
  .file-win, .drive-win { resize: none; }
  .menu { max-width: calc(100vw - 16px); }
}
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }
