/* Touch-only finishing layer. Original source sprites remain unmodified. */
.desktop-client.touch-client {
  --mobile-rail-right: env(safe-area-inset-right, 0px);
  --mobile-rail-top: env(safe-area-inset-top, 0px);
}

/* The source rail body already contains an entire column of icons. Never tile
   it underneath the eight live controls. Keep just the original orb crown. */
.desktop-client.touch-client #rail-toggle {
  top: var(--mobile-rail-top);
  right: var(--mobile-rail-right);
  width: 44px;
  height: 44px;
  min-height: 44px;
  z-index: 15;
}
.desktop-client.touch-client #rail-toggle::before,
.desktop-client.touch-client #rail-toggle[aria-expanded="false"]::before {
  left: calc(50% - 75.65px);
  top: calc(50% - 20.4px);
  width: 94.35px;
  height: 98.6px;
  background: url('/assets/ui/rail-0-0.png') center / contain no-repeat;
  /* The lower pendant otherwise sits behind two unrelated live buttons. */
  clip-path: inset(0 0 37px 0);
}
.desktop-client.touch-client .function-rail {
  top: calc(var(--mobile-rail-top) + 60px);
  right: var(--mobile-rail-right);
  bottom: max(2px, env(safe-area-inset-bottom, 0px));
  width: 44px;
  height: auto;
  max-height: none;
  gap: 0;
  padding: 0;
  border: 0;
  background: none !important;
  box-shadow: none;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  scroll-padding: 0;
  scroll-snap-type: y proximity;
  touch-action: pan-y;
}
.desktop-client.touch-client .function-rail::-webkit-scrollbar { display: none; }
.desktop-client.touch-client .function-rail::before,
.desktop-client.touch-client .function-rail::after,
.desktop-client.touch-client .function-rail > .rail-orb { display: none !important; }
.desktop-client.touch-client .function-rail > button {
  width: 44px;
  height: 44px;
  min-height: 44px;
  flex: 0 0 44px;
  box-shadow: none;
  scroll-snap-stop: normal;
}
.desktop-client.touch-client .function-rail > button::before { inset: 3px; }
.desktop-client.touch-client .function-rail > button::after {
  inset: 7px;
  background-size: 30px 30px;
}
.desktop-client.touch-client .function-rail .rail-custom-icon > .rail-native-icon { inset: 7px; }

/* Compact original chat materials with a quiet, opaque reading surface.
   Position and width remain under the existing floating / resize handlers. */
.desktop-client.touch-client #chat-box.chat-box {
  border: 3px solid transparent;
  border-image: url('/assets/ui/native-detail-frame.png') 7 / 3px / 0 stretch;
  border-radius: 0;
  background: linear-gradient(#11170ff5, #11170ff5), url('/assets/ui/native-detail-wood.png');
  box-shadow: 0 2px 7px #0008;
  overflow: hidden;
  color: #f2ead6;
}
.desktop-client.touch-client #chat-box .chat-header {
  position: relative;
  height: 34px;
  min-height: 34px;
  padding: 5px 12px 0 17px;
  background: linear-gradient(#13160cb0, #13160c55), url('/assets/ui/native-detail-wood.png') center;
  font: 12px/1.2 var(--font);
  color: #f5dfaf;
  text-shadow: 0 1px 2px #000;
}
.desktop-client.touch-client #chat-box .chat-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 12px;
  right: 12px;
  height: 7px;
  margin: 0;
  background: url('/assets/ui/chat-0-0.png') center -26px / 632px 67px no-repeat;
  opacity: .85;
  pointer-events: none;
}
.desktop-client.touch-client #chat-box .chat-header > span { position: relative; }
.desktop-client.touch-client #chat-box #chat-collapse {
  position: relative;
  width: 32px;
  height: 30px;
  min-height: 30px;
  flex: 0 0 32px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: url('/assets/ui/chat-3-0.png') center / 21px 20px no-repeat;
  color: #fff0c4;
  font: 17px/30px var(--font);
  text-shadow: 0 1px 2px #000;
  box-shadow: none;
  touch-action: manipulation;
}
.desktop-client.touch-client #chat-box .chat-tabs {
  display: flex;
  height: 30px;
  margin: 0 10px;
  gap: 0;
  border: 0;
  border-bottom: 1px solid #8b794e80;
  background: #11170f;
}
.desktop-client.touch-client #chat-box .chat-tabs button {
  flex: 1 1 0;
  min-width: 0;
  height: 30px;
  min-height: 30px;
  margin: 0;
  padding: 0 3px;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: #c6c3aa;
  font: 12px/30px var(--font);
  white-space: nowrap;
}
.desktop-client.touch-client #chat-box .chat-tabs button.active {
  background-color: #b79c5721;
  box-shadow: inset 0 -2px #d7b878;
  color: #ffe6ac;
}
.desktop-client.touch-client #chat-box .chat-tabs button[data-chat-tab="nearby"] {
  background-image: url('/assets/ui/chat-6-0.png');
  background-position: 5px center;
  background-size: 17px 18px;
  background-repeat: no-repeat;
  padding-left: 21px;
}
.desktop-client.touch-client #chat-box .chat-tabs button[data-chat-tab="world"] {
  background-image: url('/assets/ui/chat-9-0.png');
  background-position: 5px center;
  background-size: 16px 19px;
  background-repeat: no-repeat;
  padding-left: 21px;
}
.desktop-client.touch-client #chat-box .chat-messages {
  box-sizing: border-box;
  height: clamp(44px, calc(var(--floating-available-height, 260px) - 120px), 84px);
  margin: 0 10px;
  padding: 7px 13px;
  background: url('/assets/ui/chat-2-0.png') center / 100% 100% no-repeat, #090e09;
  color: #f2ead6;
  font: 12px/18px var(--font);
  text-shadow: 0 1px #000;
  scrollbar-color: #94805a #13180f;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.desktop-client.touch-client #chat-box .chat-row { padding: 1px 0; }
.desktop-client.touch-client #chat-box .chat-row.system { color: #d5e1be; }
.desktop-client.touch-client #chat-box .chat-row .chat-name { color: #f3d692; }
.desktop-client.touch-client #chat-box .chat-row time { color: #a9b0a0; font-size: 10px; }
.desktop-client.touch-client #chat-box form {
  box-sizing: border-box;
  height: 36px;
  margin: 0 10px 3px;
  padding: 2px;
  gap: 3px;
  border: 1px solid #8b794e80;
  background: #0b110b;
}
.desktop-client.touch-client #chat-box input {
  box-sizing: border-box;
  height: 30px;
  min-height: 30px;
  padding: 3px 5px;
  border: 0;
  background: none;
  color: #fff3d7;
  font: 16px/24px var(--font);
}
.desktop-client.touch-client #chat-box input::placeholder { color: #aeb49f; font-size: 12px; }
.desktop-client.touch-client #chat-box form button {
  height: 30px;
  min-height: 30px;
  padding: 0 8px;
  border: 0;
  border-left: 1px solid #8b794e80;
  background: #413d2440;
  color: #f4dfaa;
  font: 12px/30px var(--font);
}
.desktop-client.touch-client #chat-box .chat-resize {
  width: 11px;
  color: #c5a76d;
}
.desktop-client.touch-client #chat-box .chat-resize::before {
  top: 12px;
  bottom: 12px;
  opacity: .7;
}
.desktop-client.touch-client #chat-box.collapsed :is(.chat-tabs, .chat-messages, form) { display: none; }
.desktop-client.touch-client #chat-box :is(.chat-tabs button, #chat-collapse, form button):focus-visible {
  outline: 1px solid #f1d69a;
  outline-offset: -2px;
}
@media (max-height: 350px) {
  .desktop-client.touch-client #chat-box .chat-messages { max-height: 66px; }
}
