/* RelayDesk website layout. Tokens and components live in /shared/base.css. */

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

svg {
  flex: none;
}

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

/* ---------------------------------------------------------------- auth */
.auth {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 40px 16px;
  background:
    radial-gradient(1100px 500px at 50% -10%, var(--accent-soft), transparent 70%),
    var(--bg);
}

.auth-wrap {
  width: min(420px, 100%);
  display: grid;
  gap: 24px;
}

.auth-brand {
  justify-self: center;
  font-size: 22px;
}

.auth-brand svg {
  width: 36px;
  height: 36px;
}

.auth-card {
  padding: 8px 24px 24px;
  display: grid;
  gap: 18px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--border);
  margin: 0 -24px;
  padding: 0 24px;
}

.tabs:has(> [hidden]) {
  grid-template-columns: 1fr;
}

.tabs button {
  height: 46px;
  border: 0;
  background: none;
  color: var(--text-2);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tabs button[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.auth-points {
  list-style: none;
  margin: 0;
  padding: 0 4px;
  display: grid;
  gap: 14px;
  color: var(--text-2);
  font-size: 13.5px;
}

.auth-points li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.auth-points svg {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  color: var(--accent);
}

.auth-points b {
  color: var(--text);
  font-weight: 600;
}

/* ---------------------------------------------------------------- shell */
.shell {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 60px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-right {
  display: flex;
  gap: 4px;
  min-width: 0;
}

#who {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 32px 24px 48px;
  display: grid;
  gap: 24px;
  align-content: start;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-head h1 {
  font-size: 26px;
  margin-bottom: 4px;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}

.device {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.device-top {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.device-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--text-2);
  flex: none;
}

.device.online .device-icon {
  background: var(--accent-soft);
  color: var(--accent);
}

.device-icon svg {
  width: 22px;
  height: 22px;
}

.device-meta {
  flex: 1;
  min-width: 0;
}

.device-meta h3 {
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-status {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.device-key {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-3);
}

.device-key svg {
  width: 14px;
  height: 14px;
}

.device-key.verified svg {
  color: var(--ok);
}

.device-key.unverified {
  color: var(--danger);
}

.empty {
  padding: 48px 24px;
  text-align: center;
  display: grid;
  gap: 12px;
  justify-items: center;
}

.empty p {
  max-width: 440px;
}

.empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
}

.empty-icon svg {
  width: 28px;
  height: 28px;
}

.key-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.key-line svg {
  width: 14px;
  height: 14px;
}

/* ---------------------------------------------------------------- menus */
.menu-wrap {
  position: relative;
}

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 210px;
  padding: 6px;
  z-index: 20;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: grid;
}

.menu button {
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.menu button:hover,
.menu button:focus-visible {
  background: var(--surface-2);
  outline: none;
}

.menu button.danger {
  color: var(--danger);
}

/* ---------------------------------------------------------------- dialogs */
.dialog {
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

.dialog-sm {
  width: min(400px, calc(100vw - 32px));
}

.dialog::backdrop {
  background: rgba(8, 10, 14, 0.55);
  backdrop-filter: blur(2px);
}

.dialog-body {
  padding: 20px 24px 24px;
  display: grid;
  gap: 16px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-head h2 {
  font-size: 18px;
}

.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.steps {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 12px;
  color: var(--text-2);
}

.steps b {
  color: var(--text);
}

.copyable {
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text);
  user-select: all;
  word-break: break-all;
}

.sep {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

.danger-zone h3 {
  color: var(--danger);
}

.form h3 {
  font-size: 15px;
}

/* ---------------------------------------------------------------- remote session */
.remote {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--stage);
  color: #e9ecf1;
}

.rbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 52px;
  padding: 0 10px;
  background: #12151b;
  border-bottom: 1px solid #222833;
  flex: none;
}

.rbar .btn-ghost {
  color: #b9c0cc;
}

.rbar .btn-ghost:hover {
  background: #1d222b;
  color: #fff;
}

.rbar select {
  height: 32px;
  width: auto;
  font-size: 13px;
  background-color: #1b2029;
  border-color: #2c3340;
  color: #e9ecf1;
}

.rbar > .btn {
  flex: none;
}

.rbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 1 auto;
  min-width: 0;
}

.rbar-title b {
  min-width: 3ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rbar-title .badge {
  flex: none;
}

.rbar-title .badge svg {
  width: 13px;
  height: 13px;
}

.rbar .badge.ok {
  background: rgba(60, 207, 122, 0.14);
  color: #5fdc93;
}

.rbar-stats {
  flex: 1 1 0;
  min-width: 0;
  font-size: 12px;
  color: #7c8594;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}

.rbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
}

.rbar .menu {
  background: #1b2029;
  border-color: #2c3340;
}

.rbar .menu button {
  color: #e9ecf1;
}

.rbar .menu button:hover {
  background: #262d38;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.stage canvas {
  display: block;
  background: #000;
  outline: none;
  touch-action: none;
  image-rendering: auto;
}

.stage canvas:focus-visible {
  box-shadow: 0 0 0 2px var(--accent);
}

.stage-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: rgba(11, 13, 17, 0.82);
  color: #c9d0da;
}

.overlay-icon {
  width: 32px;
  height: 32px;
  color: #ff8a8a;
}

#r-status {
  max-width: 460px;
}

.viewonly {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(18, 21, 27, 0.9);
  border: 1px solid #2c3340;
  font-size: 13px;
  color: #c9d0da;
  pointer-events: none;
}

.viewonly svg {
  width: 16px;
  height: 16px;
}

.remote:fullscreen .rbar {
  display: none;
}

/* Short notices over the remote screen (mouse lock). Inside the stage, so they also show in full screen. */
.stage-hint {
  position: absolute;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(18, 21, 27, 0.9);
  border: 1px solid #2c3340;
  font-size: 13px;
  color: #c9d0da;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s;
}

.stage-hint.show {
  opacity: 1;
}

.stage-hint b {
  color: #fff;
  font-weight: 600;
}

.rbar .btn[aria-pressed='true'] {
  background: var(--accent-soft);
  color: var(--accent);
}

body.touch .mouse-only {
  display: none !important;
}

/* ---------------------------------------------------------------- touch + phones */
.touch-only,
.narrow-only {
  display: none;
}

body.touch .touch-only {
  display: inline-flex;
}

.rbar .btn,
.extra-keys button,
.menu button {
  touch-action: manipulation;
}

.rbar .menu {
  max-height: calc(100dvh - 80px);
  overflow-y: auto;
}

.menu .menu-heading {
  padding: 8px 10px 4px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #7c8594;
}

.menu .menu-note {
  padding: 2px 10px 8px;
  font-size: 12.5px;
  color: #a4acb9;
}

.menu .menu-sep {
  height: 1px;
  margin: 6px 4px;
  background: #2c3340;
}

.menu button[aria-checked="true"]::after {
  content: "✓";
  float: right;
  color: #5fdc93;
}

.stage {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.touch-cursor {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.65), inset 0 0 0 1.5px rgba(0, 0, 0, 0.65);
  pointer-events: none;
  will-change: transform;
}

.touch-cursor::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.65);
}

.stage.touch-held .touch-cursor {
  border-color: #5d8dff;
  transform-origin: center;
}

.extra-keys {
  display: flex;
  gap: 6px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  overflow-x: auto;
  background: #12151b;
  border-top: 1px solid #222833;
  flex: none;
  scrollbar-width: none;
}

.extra-keys button {
  flex: none;
  min-width: 46px;
  height: 40px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid #2c3340;
  background: #1b2029;
  color: #e9ecf1;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
}

.extra-keys button:active {
  background: #262d38;
}

.extra-keys button.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Receives phone-keyboard typing; kept invisible but focusable. */
.softkbd {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  resize: none;
  font-size: 16px;
  pointer-events: none;
}

.rbar {
  padding-top: env(safe-area-inset-top);
  height: calc(52px + env(safe-area-inset-top));
  padding-left: max(10px, env(safe-area-inset-left));
  padding-right: max(10px, env(safe-area-inset-right));
}

.topbar {
  padding-top: env(safe-area-inset-top);
  height: calc(60px + env(safe-area-inset-top));
}

/* ---------------------------------------------------------------- small screens */
@media (max-width: 960px) {
  .rbar-stats {
    visibility: hidden;
  }
}

@media (max-width: 720px) {
  .hide-sm {
    display: none;
  }

  .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }

  .page {
    padding: 24px 16px 40px;
  }

  .rbar {
    gap: 4px;
    height: calc(48px + env(safe-area-inset-top));
  }

  .rbar-stats,
  .wide-only {
    display: none !important;
  }

  .narrow-only {
    display: block;
  }

  .rbar-title {
    flex: 1 1 auto;
  }

  .rbar-title .badge {
    display: none;
  }
}

@media (max-width: 420px) {
  #r-mode-label {
    display: none;
  }

  #r-mode {
    width: 34px;
    padding: 0;
  }
}
