:root {
  color-scheme: light;
  --ink: #131514;
  --graphite: #2f2f2f;
  --concrete: #707070;
  --silver: #b0b0b0;
  --chalk: #f4f4f4;
  --paper: #efefef;
  --rule: #d0d0d0;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--chalk);
}
* { box-sizing: border-box; }
body { margin: 0; height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; padding-inline: env(safe-area-inset-left) env(safe-area-inset-right); }
header, footer { display: flex; align-items: center; justify-content: space-between; padding-inline: clamp(16px, 3vw, 48px); gap: 14px; }
header { padding-block: calc(14px + env(safe-area-inset-top)) 14px; border-bottom: 1px solid var(--rule); }
footer { padding-block: 13px calc(13px + env(safe-area-inset-bottom)); border-top: 1px solid var(--rule); font-size: 12px; color: #555; }
.brand, .actions, #status, .legend { display: flex; align-items: center; gap: 10px; }
.brand { gap: 4px; font-weight: 700; letter-spacing: -.025em; font-size: clamp(18px, 3vw, 23px); }
.heading { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
#count { font-size: 12px; color: #555; white-space: nowrap; }
#count:not(:empty)::before { content: '/'; margin-right: 10px; }
.mark { display: block; flex: none; }
button, input, textarea { font: inherit; color: inherit; }
button, .map-switch { cursor: pointer; background: var(--chalk); border: 1px solid #bcbcbc; padding: 9px 13px; min-height: 38px; font-size: 13px; }
.map-switch { display: inline-flex; align-items: center; color: inherit; text-decoration: none; }
.short-label { display: none; }
button:hover, .map-switch:hover { background: #e5e5e5; }
button.primary { color: white; background: var(--ink); border-color: var(--ink); }
button.primary:hover { background: #3a3a3a; }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid #526b61; outline-offset: 3px; }
main { position: relative; overflow: hidden; background: radial-gradient(circle, #ccc 0.7px, transparent 1px) center / 23px 23px, var(--paper); }
#map { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; user-select: none; }
#map.dragging, #map.dragging .space, #map.dragging .link { cursor: grabbing; }
.title { position: absolute; left: clamp(16px, 4vw, 64px); top: clamp(18px, 5vh, 60px); pointer-events: none; }
.title { transition: opacity 200ms ease-out; }
.title.dismissed { opacity: 0; }
h1 { font-size: clamp(31px, 5.4vw, 80px); margin: 0; line-height: .92; letter-spacing: -.04em; font-weight: 630; }
.space { cursor: pointer; }
.link { cursor: grab; }
#sound[aria-pressed="false"] { color: #666; text-decoration: line-through; }
.connection-handle { cursor: crosshair; }
.connection-handle .handle-dot { fill: var(--ink); stroke: var(--chalk); stroke-width: 1.5; }
.connection-handle path { fill: none; stroke: var(--chalk); stroke-width: 1.25; pointer-events: none; }
.connection-minus { cursor: pointer; }
.connection-minus:focus { outline: none; }
.connection-minus:hover path, .connection-minus:focus-visible path { stroke-width: 2; }
.connection-preview { stroke: #656963; stroke-width: 1.5; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; pointer-events: none; }
#map.connecting-drag ~ #editor { visibility: hidden; }
.space text { text-anchor: middle; pointer-events: none; font-weight: 650; }
.space.held { cursor: grabbing; }
.space:focus { outline: none; }
.space:focus-visible text { font-weight: 800; }
.link .visible { stroke: #656963; }
.link line { vector-effect: non-scaling-stroke; }
.link .hit { stroke: transparent; stroke-width: 20; }
.link:focus { outline: none; }
.link:hover .visible, .link.selected .visible, .link:focus-visible .visible { stroke: var(--ink); }
.link .visible { stroke-dasharray: 4 3; animation: active-connection 1.4s linear infinite; }
.link.selected .visible { animation-play-state: paused; }
@keyframes active-connection { to { stroke-dashoffset: -7; } }
@media (prefers-reduced-motion: reduce) { .link .visible { animation: none; } }
.navigation { position: absolute; display: flex; bottom: 18px; right: 20px; }
.navigation button + button { border-left: 0; }
#editor { position: absolute; right: 20px; top: 20px; width: min(300px, calc(100% - 40px)); padding: 17px; background: var(--chalk); border: 1px solid #bcbcbc; max-height: calc(100% - 85px); overflow: auto; }
#editor.connection-editor { right: auto; bottom: auto; width: min(230px, calc(100% - 20px)); padding: 10px 12px; }
.connection-editor .panel-head { margin-bottom: 7px; }
.connection-editor h2 { font-size: 14px; }
.connection-editor form { gap: 6px; }
.connection-editor .form-actions { justify-content: space-between; }
.connection-editor button { padding: 4px 8px; min-height: 28px; }
@media (min-width: 651px) { #editor.editor-left { left: 20px; right: auto; } }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 15px; }
#editor .panel-head { cursor: grab; touch-action: none; user-select: none; }
#editor .panel-head:active { cursor: grabbing; }
.panel-title { display: flex; align-items: center; gap: 8px; }
.panel-grip { flex: 0 0 10px; height: 15px; color: #62625f; background: radial-gradient(circle, currentColor 1px, transparent 1.4px) 0 0 / 5px 5px; }
h2 { margin: 0; font-size: 19px; letter-spacing: -.025em; }
form { display: grid; gap: 12px; }
label { display: grid; gap: 5px; font-size: 13px; }
input, textarea { min-width: 0; width: 100%; background: #fff; border: 1px solid #aaa; padding: 8px; border-radius: 0; font-size: 16px; }
textarea { resize: vertical; }
.slider-label { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.slider-label output, #room-connections button span { font-variant-numeric: tabular-nums; color: #555; }
input[type="range"] { margin: 0; padding: 0; accent-color: var(--ink); background: transparent; border: 0; min-height: 28px; cursor: pointer; }
#room-connections h3 { font-size: 13px; margin: 0 0 6px; }
#room-connections p { color: #555; font-size: 13px; }
#room-connections ul { list-style: none; padding: 0; margin: 0; }
#room-connections button { display: flex; justify-content: space-between; width: 100%; text-align: left; gap: 10px; border-width: 1px 0 0; padding-inline: 0; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.compact-action { display: none; }
form p { margin: 0; overflow-wrap: anywhere; }
#empty, #message { position: absolute; left: 50%; transform: translateX(-50%); background: var(--chalk); padding: 10px 14px; border: 1px solid var(--rule); text-align: center; }
#empty { top: 50%; }
#message { bottom: 68px; max-width: 85%; }
#status { white-space: nowrap; }
#status i { width: 7px; height: 7px; border-radius: 50%; background: #8f7152; }
#status.online i { background: #526b61; }
.legend b { height: 3px; width: 15px; background: #656963; }
.session { display: flex; flex-wrap: wrap; min-width: 0; align-items: center; gap: 8px 12px; }
#identity { min-height: 0; min-width: 0; max-width: 100%; padding: 0; border: 0; font: inherit; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#editors { display: contents; }
.editor-name { max-width: 100%; overflow-wrap: anywhere; }
#people { pointer-events: none; }
.peer-pointer { fill: var(--ink); stroke: var(--chalk); stroke-width: 1.5; stroke-linejoin: round; }
.peer-label { fill: var(--chalk); font-size: 11px; font-weight: 600; }
.peer-pill { fill: var(--ink); }
.peer-tag-edit .peer-pill { fill: var(--chalk); stroke: #bcbcbc; stroke-width: .75; }
.peer-tag-edit .peer-label { fill: var(--ink); }
dialog { border: 1px solid #aaa; background: var(--chalk); color: var(--ink); padding: 24px; width: min(340px, calc(100% - 32px)); }
dialog::backdrop { background: #13151473; }
dialog p { font-size: 14px; line-height: 1.45; margin: 10px 0 16px; }
dialog button { justify-self: start; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
#remove-dialog p { overflow-wrap: anywhere; }
#remove-title { overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) {
  .title { transition: none; }
}
body.expanded { grid-template-rows: 0 minmax(0, 1fr) 0; }
body.expanded .title { opacity: 0; }
.expanded header, .expanded footer { visibility: hidden; pointer-events: none; }
#exit-fullscreen {
  position: absolute;
  z-index: 3;
  inset: calc(8px + env(safe-area-inset-top)) auto auto 50%;
  transform: translateX(-50%);
  min-height: 44px;
  border: 0;
  background: var(--paper);
  touch-action: none;
}
.expanded .navigation { bottom: calc(18px + env(safe-area-inset-bottom)); }
@media (max-width: 700px), (any-pointer: coarse) {
  /* The bars handle taps. The map handles its own pinch and pan gestures. */
  header, footer, .navigation { touch-action: none; }
  #editor, dialog { touch-action: manipulation; }
}
@media (max-width: 700px), (pointer: coarse) and (max-height: 550px) {
  body { overflow: hidden; }
  header { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  header { flex-wrap: wrap; gap: 8px; padding-block: calc(8px + env(safe-area-inset-top)) 8px; }
  header button, .map-switch { padding-inline: 8px; }
  .actions { flex-wrap: wrap; gap: 5px; }
  .wide-label { display: none; }
  .short-label { display: inline; }
  button, .map-switch, #identity, input[type="range"] { min-height: 44px; }
  .navigation button { min-width: 44px; }
  .legend { display: none; }
  footer { padding-block: 0 env(safe-area-inset-bottom); min-height: 44px; }
  .session { width: 100%; flex-wrap: nowrap; gap: 9px; }
  #status { flex-shrink: 0; }
  #identity { max-width: 50%; }
  #editors:not(:empty) {
    display: flex;
    min-width: 0;
    gap: 9px;
    overflow-x: auto;
    scrollbar-width: none;
    touch-action: pan-x;
  }
  .editor-name { flex-shrink: 0; max-width: none; white-space: nowrap; padding-block: 6px; }
  #editor, #editor.connection-editor {
    inset: auto 0 0 !important;
    width: auto;
    padding: 0 16px;
    max-height: 58%;
    border-width: 1px 0 0;
    overscroll-behavior: contain;
  }
  .expanded #editor { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  #editor .panel-head { position: sticky; top: 0; z-index: 1; background: var(--chalk); cursor: default; touch-action: auto; padding-block: 8px; margin-bottom: 4px; }
  #editor .panel-grip { display: none; }
  #editor button { min-height: 44px; }
  #editor .form-actions { position: sticky; bottom: 0; padding-block: 8px; background: var(--chalk); border-top: 1px solid var(--rule); }
  #editor.keyboard-open {
    position: fixed;
    inset: var(--keyboard-editor-top) env(safe-area-inset-right) auto env(safe-area-inset-left) !important;
    z-index: 4;
    height: var(--keyboard-editor-height);
    max-height: none;
    padding-bottom: 12px;
  }
  #editor.keyboard-open .form-actions { position: static; }
  .compact-action { display: inline-block; justify-self: start; }
  .navigation { right: 12px; bottom: 12px; }
  #editor:not([hidden]) ~ .navigation { display: none; }
  #editor:not([hidden]) ~ #message { top: 8px; bottom: auto; z-index: 2; }
}
@media (display-mode: standalone) and (max-width: 700px) {
  header { padding-block-start: calc(20px + env(safe-area-inset-top)); }
}
@media (pointer: coarse) {
  .link .hit { stroke-width: 32; }
}
