/* Static drawing materials, shared by web components and the embedded Rust UI. */
:root {
  --chalk-grain: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20width%3D%2764%27%20height%3D%2764%27%3E%3Cfilter%20id%3D%27chalk%27%20x%3D%270%27%20y%3D%270%27%20width%3D%27100%25%27%20height%3D%27100%25%27%3E%3CfeTurbulence%20type%3D%27fractalNoise%27%20baseFrequency%3D%27.9%27%20numOctaves%3D%273%27%20seed%3D%2717%27%20stitchTiles%3D%27stitch%27%20result%3D%27noise%27%2F%3E%3CfeColorMatrix%20in%3D%27noise%27%20type%3D%27matrix%27%20values%3D%270%200%200%200%201%200%200%200%200%201%200%200%200%200%201%204%200%200%200%20-1.25%27%2F%3E%3C%2Ffilter%3E%3Cpath%20fill%3D%27white%27%20filter%3D%27url%28%23chalk%29%27%20d%3D%27M0%200h64v64H0z%27%2F%3E%3C%2Fsvg%3E");
  --chalk-rule: var(--pencil-line-mask) center / 100% 100% no-repeat intersect,
    var(--chalk-grain) top left / 64px 64px repeat;
  --pencil-grain: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20width%3D%2764%27%20height%3D%2764%27%3E%3Cdefs%3E%3Cfilter%20id%3D%27tooth%27%20x%3D%270%27%20y%3D%270%27%20width%3D%27100%25%27%20height%3D%27100%25%27%3E%3CfeTurbulence%20type%3D%27fractalNoise%27%20baseFrequency%3D%27.85%27%20numOctaves%3D%273%27%20seed%3D%277%27%20stitchTiles%3D%27stitch%27%20result%3D%27noise%27%2F%3E%3CfeColorMatrix%20in%3D%27noise%27%20type%3D%27matrix%27%20values%3D%270%200%200%200%201%200%200%200%200%201%200%200%200%200%201%202.4%200%200%200%20-.45%27%20result%3D%27grain%27%2F%3E%3CfeComposite%20in%3D%27SourceGraphic%27%20in2%3D%27grain%27%20operator%3D%27in%27%2F%3E%3C%2Ffilter%3E%3C%2Fdefs%3E%3Cpath%20fill%3D%27white%27%20filter%3D%27url%28%23tooth%29%27%20d%3D%27M0%200h64v64H0z%27%2F%3E%3C%2Fsvg%3E");
  --pencil-line-mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%20320%208%27%20preserveAspectRatio%3D%27none%27%3E%3Cg%20fill%3D%27white%27%3E%3Cpath%20d%3D%27M2%204.4C44%203.2%20112%203.1%20164%203.3S274%203.2%20318%204.2C271%204.7%20225%204.9%20168%204.8S50%205%202%204.4Z%27%2F%3E%3Cpath%20d%3D%27M15%205.4Q158%205%20303%205.2%27%20fill%3D%27none%27%20stroke%3D%27white%27%20stroke-width%3D%27.35%27%20opacity%3D%27.35%27%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E");
  --pencil-rule: var(--pencil-line-mask) center / 100% 100% no-repeat intersect,
    var(--pencil-grain) top left / 64px 64px repeat;
}

/* Apply texture only to decorative strokes, never text or the hit target. */
.pencil-mark,
.pencil-outline,
.chalk-outline {
  -webkit-mask-image: var(--pencil-grain);
  mask-image: var(--pencil-grain);
  -webkit-mask-size: 64px 64px;
  mask-size: 64px 64px;
  pointer-events: none;
}

.pencil-outline,
.chalk-outline {
  position: absolute;
  inset: 0;
  border: 1.5px solid currentColor;
  border-radius: inherit;
  opacity: .72;
}

.pencil-outline::after {
  content: "";
  position: absolute;
  inset: -.4px .3px .4px -.3px;
  border: .5px solid currentColor;
  border-radius: inherit;
  opacity: .24;
}

/* Broad, porous chalk with a faint offset dust edge; never blur the content. */
.chalk-outline {
  border-width: 2px;
  opacity: .85;
  -webkit-mask-image: var(--chalk-grain);
  mask-image: var(--chalk-grain);
}

.chalk-outline::after {
  content: "";
  position: absolute;
  inset: -.8px .5px .6px -.5px;
  border: 1px solid currentColor;
  border-radius: inherit;
  opacity: .3;
}

.pencil-line {
  background: currentColor;
  -webkit-mask: var(--pencil-rule);
  mask: var(--pencil-rule);
  pointer-events: none;
}

@media (forced-colors: active) {
  .pencil-mark,
  .pencil-outline,
  .chalk-outline,
  .pencil-line {
    -webkit-mask: none;
    mask: none;
    opacity: 1;
  }

  .pencil-line {
    height: 1px;
    background: CanvasText;
    forced-color-adjust: none;
  }
}

:root {
  color-scheme: light dark;
  --paper: #f7f5f0;
  --ink: #1c1b19;
  --quiet: #7a766e;
  --accent: #c2491c;
  --text: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #161513;
    --ink: #ecebe6;
    --quiet: #8f8b82;
    --accent: #ef7a4a;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 13px/1.5 var(--text);
  -webkit-font-smoothing: antialiased;
}

h1 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.02em;
}

p {
  margin: 0;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

.quiet {
  color: var(--quiet);
}

.error {
  color: var(--accent);
}

/* Chalk rules keep the controls precise, with porous edges and tapered pressure. */
.link,
.action,
#desktops a {
  position: relative;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.action {
  color: var(--accent);
  font-weight: 500;
}

.action:disabled {
  color: var(--quiet);
  cursor: default;
}

.chalk-field::after,
.link:hover:not(:disabled)::after,
.action:hover:enabled::after,
#desktops a:hover .name::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -3px;
  height: 6px;
  background: currentColor;
  -webkit-mask: var(--chalk-rule);
  mask: var(--chalk-rule);
}

.field {
  position: relative;
  display: inline-block;
  color: var(--quiet);
}

.field:focus-within {
  color: var(--ink);
}

/* Focus stays crisp where the chalk mask has small gaps. */
.field:focus-within::after {
  height: 2px;
  background: var(--accent);
  -webkit-mask: none;
  mask: none;
}

.field input {
  width: 100%;
  padding: 2px 0 6px;
  border: 0;
  outline: 0;
  background: none;
  color: var(--ink);
}

input::placeholder {
  color: var(--quiet);
}

/* Sign in */

#signin {
  min-height: 100%;
  display: grid;
  place-content: center;
  gap: 32px;
  padding: 24px;
}

#signin h1 {
  font-size: 48px;
}

#signin form {
  display: flex;
  align-items: baseline;
  gap: 24px;
}

#code {
  width: 13ch;
  font-size: 22px;
  font-family: var(--mono);
}

#oidc {
  justify-self: start;
}

/* Desktops */

#home {
  max-width: 1600px;
  margin: 0 auto;
  padding: 40px clamp(20px, 4vw, 64px) 72px;
  display: grid;
  gap: 32px;
}

#home header {
  display: flex;
  align-items: baseline;
  gap: 24px;
}

#home h1 {
  margin-right: auto;
  font-size: 22px;
}

#add-toggle {
  font-size: 26px;
  line-height: 1;
}

#desktops {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
  gap: 28px;
  margin: 0;
  padding: 0;
  list-style: none;
}

#desktops a {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

#desktops .name {
  position: relative;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

#pair {
  display: flex;
  align-items: baseline;
  gap: 24px;
}

#pair-name {
  width: 18ch;
}

#pairing {
  display: grid;
  gap: 6px;
  margin-top: 28px;
}

#tokens {
  display: grid;
  gap: 8px;
  margin: 40px 0 0;
  padding: 0;
  list-style: none;
}

#tokens li {
  display: flex;
  align-items: baseline;
  gap: 16px;
}

#tokens .link {
  margin-left: auto;
  color: var(--quiet);
}

#command,
#windows-command {
  font: 15px/1.5 var(--mono);
  overflow-wrap: anywhere;
  user-select: all;
  -webkit-user-select: all;
}

/* Viewer */

/* The bottom padding keeps the remote screen clear of the footer. */
#viewer {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(48px + env(safe-area-inset-bottom));
}

#keyboard {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 16px;
  padding: 12px 18px;
}

#keyboard .field { flex: 1; min-width: 120px; }
#keyboard input { font-size: 16px; }
#keyboard-error { flex-basis: 100%; }
#keyboard-error:empty { display: none; }
#keyboard-type:disabled { color: var(--quiet); cursor: default; }
#keyboard-toggle[aria-expanded="true"] { color: var(--accent); }

#viewer nav {
  display: flex;
  align-items: baseline;
  gap: 24px;
  padding: 10px 18px;
  font-size: 14px;
  white-space: nowrap;
}

#title {
  font-weight: 600;
}

#status {
  margin-right: auto;
  overflow: hidden;
  text-overflow: ellipsis;
}

#modifiers {
  display: flex;
  gap: 14px;
  color: var(--quiet);
}

/* A held modifier reads as pressed ink. */
#modifiers [aria-pressed="true"] {
  color: var(--ink);
  font-weight: 600;
}

#quality {
  padding: 0;
  border: 0;
  background: none;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  outline: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Paste and the keyboard, for screens worked by touch. */
#touch-bar {
  display: none;
  justify-content: space-between;
  padding: 10px 18px 0;
  font-size: 16px;
}

@media (pointer: coarse) {
  #touch-bar { display: flex; }
}
.remote-cursor {
  position: absolute;
  pointer-events: none;
  z-index: 1;
}

#notice {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  pointer-events: none;
}

.privacy { display: grid; gap: 24px; max-width: 720px; padding: 64px 24px; margin: auto; }
footer { display: flex; gap: 24px; position: fixed; bottom: 16px; right: 20px; z-index: 2; }

.screen-preview {
  position: relative;
  display: block;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: color-mix(in srgb, var(--ink) 5%, var(--paper));
  border-radius: 6px;
  margin-bottom: 6px;
}

.screen-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.screen-notice {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  padding: 24px;
  text-align: center;
}

.screen-detail { font-size: 12px; }

#add { max-width: 720px; }

#pair { flex-wrap: wrap; gap: 16px 24px; }

#oidc { color: var(--accent); font-size: 18px; }

button, a, select { transition: opacity 150ms ease; }
a:focus-visible, button:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 6px;
}
button:active, a:active { opacity: .65; }

@media (max-width: 600px) {
  #home { padding: 28px 20px 72px; }
  #home header { gap: 20px; }
  #viewer nav { gap: 16px; flex-wrap: wrap; }
  #status { flex-basis: 100%; order: 1; font-size: 12px; }
  #title { margin-right: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

.downloads { display: flex; flex-wrap: wrap; gap: 24px; margin-bottom: 24px; }
#add details { margin-top: 16px; }
#add summary { cursor: pointer; color: var(--quiet); }
#add details[open] summary { margin-bottom: 20px; }
#tokens { margin-top: 0; }

@media (forced-colors: active) {
  .chalk-field::after,
  .link:hover:not(:disabled)::after,
  .action:hover:enabled::after,
  #desktops a:hover .name::after {
    height: 1px;
    -webkit-mask: none;
    mask: none;
    background: CanvasText;
    forced-color-adjust: none;
  }

  .field:focus-within::after {
    height: 2px;
    background: Highlight;
  }
}
