:root {
  --paper: #ffcf00;
  --ink: #300f0a;
  --screen: #300f0a;
  --screen-ink: #ffcf00;
  --hatch: repeating-linear-gradient(135deg, var(--ink) 0 1px, transparent 1px 4px);
  --bar: 32px;
  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, .statusbar {
  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); }
.statusbar { bottom: 0; border-top: 2px solid var(--ink); font-size: 11px; gap: 14px; }
.menubar nav { display: flex; gap: 18px; }
.menubar nav button:hover, .menubar nav button[aria-current] { background: var(--ink); color: var(--paper); }
.menubar nav button { padding: 2px 5px; }
.apple { color: inherit; text-decoration: none; font-size: 18px; }
.menubar-status { font-size: 10px; animation: beat 2.4s ease-in-out infinite; }
.menubar-status.stale { animation: none; opacity: .35; }
@keyframes beat { 0%, 70%, 100% { opacity: 1 } 80% { opacity: .2 } }
.ticker { max-width: 50vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.desktop { position: absolute; inset: var(--bar) 0 var(--bar) 0; }
.margin-note { position: absolute; left: 22px; top: 36px; margin: 0; line-height: 1.5; font-size: 12px; letter-spacing: .04em; }

.icons { position: absolute; right: 18px; top: 22px; list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; z-index: 1; }
.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 { 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; }

/* terminal */
.term-body { background: var(--screen); color: var(--screen-ink); margin: 6px; padding: 14px 16px; height: 300px; display: flex; flex-direction: column; cursor: text; }
.term { flex: 1; overflow-y: auto; white-space: pre-wrap; line-height: 1.6; scrollbar-width: none; }
.term a { color: inherit; }
.term .ok { opacity: .7; }
.term-line { display: flex; gap: 8px; }
.term-line label { white-space: nowrap; }
.term-line input { flex: 1; min-width: 0; font: inherit; color: inherit; background: none; border: 0; outline: 0; caret-color: var(--screen-ink); }
.term-line { position: relative; }

/* rig */
.machine { display: grid; grid-template-columns: 1fr; margin-bottom: 10px; }
.machine strong { text-transform: uppercase; letter-spacing: .06em; }
.machine em { font-style: normal; font-size: 11px; opacity: .7; }

/* finder */
.finder { padding: 0 14px 16px; }
.path { margin: 0 -14px 14px; padding: 8px 14px; border-bottom: 2px solid var(--ink); font-size: 12px; }
.folders { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 14px 8px; }
.folder { display: grid; justify-items: center; gap: 4px; width: 100%; text-align: center; padding: 6px 2px; }
.folder svg { width: 54px; height: 44px; fill: var(--paper); stroke: var(--ink); stroke-width: 2.4; stroke-linejoin: round; transition: transform .15s; }
.folder:hover svg { transform: translateY(-2px); }
.folder:hover span, .folder:focus-visible span { background: var(--ink); color: var(--paper); }
.folder small { font-size: 11px; opacity: .75; }
.heartbeat.live::before { content: "● "; animation: beat 1.6s infinite; }

/* project window */
.beat { display: flex; gap: 3px; align-items: flex-end; height: 34px; margin: 12px 0 6px; }
.beat i { flex: 1; background: var(--ink); min-height: 2px; transform-origin: bottom; animation: grow .5s backwards cubic-bezier(.2, .9, .3, 1.2); }
@keyframes grow { from { transform: scaleY(0) } }
.drops { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin: 12px 0; }
.drops img, .drops video { width: 100%; aspect-ratio: 4/3; object-fit: cover; border: 2px solid var(--ink); display: block; filter: grayscale(1) contrast(1.1); transition: filter .2s; }
.drops a:hover img, .drops a:hover video { filter: none; }

/* 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-empty { color: var(--screen-ink); text-align: center; line-height: 1.7; padding: 20px; }
.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; }
.drops:empty::before { content: "no drops yet"; font-size: 11px; opacity: .6; }
.more a { color: inherit; }

/* notes */
.notes { margin: 0; padding: 14px 16px 16px 44px; max-height: 260px; overflow-y: auto; line-height: 1.6; }
.notes li::marker { font-size: 11px; opacity: .6; }
.notes .title { font-weight: 600; }
.notes time { opacity: .6; font-size: 11px; }

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

/* 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; }

@media (max-width: 1100px) { .margin-note, .icons { display: none; } }
@media (max-width: 760px) {
  body { overflow: auto; }
  .desktop { position: static; padding: calc(var(--bar) + 12px) 16px calc(var(--bar) + 24px); display: grid; gap: 22px; }
  .menubar nav { display: none; }
  .margin-note, .icons { display: none; }
  .win { position: relative; left: auto !important; top: auto !important; width: auto !important; max-width: none; margin-right: 10px; }
  .win[hidden] { display: block; }
  .titlebar { cursor: default; }
  .boxes .close { pointer-events: none; }
  .term-body { height: 240px; }
  .viewer { position: fixed !important; inset: 0 !important; z-index: 2000 !important; height: auto; margin: 0; resize: none; }
  .viewer[hidden] { display: none; }
  #viewer-fit { display: none; }
  .viewer .boxes .close { pointer-events: auto; width: 22px; height: 22px; font-size: 14px; }
  .statusbar .sep, #status-active { display: none; }
  .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; }
  .file-win[hidden], .drive-win[hidden] { display: none; }
  .menu { max-width: calc(100vw - 16px); }
}
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }
